I am not understanding why is Jason.decode! returning converted error {:with_clause, %{....}}?

This is my json string

"{\"calendar\":{\"accessRole\":\"owner\",\"backgroundColor\":\"#9a9cff\",\"colorId\":\"17\",
   \"conferenceProperties\":{\"allowedConferenceSolutionTypes\":[\"hangoutsMeet\"]},
   \"defaultReminders\":[{\"method\":\"popup\",\"minutes\":30}],\"deleted\":null,
    \"description\":null,\"etag\":\"\\\"1602100079130000\\\"\",\"foregroundColor\":\"#000000\",
\"hidden\":null,\"id\":\"fakeemail@gmail.com\",\"kind\":\"calendar#calendarListEntry\",
\"location\":null,\"notificationSettings\":{\"notifications\":[{\"method\":\"email\",
\"type\":\"eventCreation\"},{\"method\":\"email\",\"type\":\"eventChange\"},
{\"method\":\"email\",\"type\":\"eventCancellation\"},
{\"method\":\"email\",\"type\":\"eventResponse\"}]},\"primary\":true,\"selected\":null,
\"summary\":\"fakeemail@gmail.com\",\"summaryOverride\":null,
\"timeZone\":\"America/Toronto\"},\"businessName\":\"Fake Systems\",
\"streetAddress\":\"1423 Islington Ave\",\"provinceStates\":\"Ontario\",
\"ZIPcodePostalCode\":\"M9B 2K7\",\"phone_number\":\"2222222222\",
\"country\":\"ca\",\"appointmentName\":\"fssdf\",
\"durationInMinute\":\"3434\",\"price\":\"900\",
\"serviceLocation\":\"atBusiness\",\"depositType\":\"None\"}"

I am getting the following error:

Preformatted textConverted error {:with_clause, %{“ZIPcodePostalCode” => “M9B 2K7”, “appointmentName” => “fssdf”, “businessName” => “Fake Systems”, “calendar” => %{“accessRole” => “owner”, “backgroundColor” => “#9a9cff”, “colorId” => “17”, “conferenceProperties” => %{“allowedConferenceSolutionTypes” => [“hangoutsMeet”]}, “defaultReminders” => [%{“method” => “popup”, “minutes” => 30}], “deleted” => nil, “description” => nil, “etag” => "“1602100079130000"”, “foregroundColor” => “#000000”, “hidden” => nil, “id” => “fakeemail07@gmail.com”, “kind” => “calendar#calendarListEntry”, “location” => nil, “notificationSettings” => %{“notifications” => [%{“method” => “email”, “type” => “eventCreation”}, %{“method” => “email”, “type” => “eventChange”}, %{“method” => “email”, “type” => “eventCancellation”}, %{“method” => “email”, “type” => “eventResponse”}]}, “primary” => true, “selected” => nil, “summary” => “fakeemail07@gmail.com”, “summaryOverride” => nil, “timeZone” => “America/Toronto”}, “country” => “ca”, “depositType” => “None”, “durationInMinute” => “3434”, “phone_number” => “2222222222”, “price” => “900”, “provinceStates” => “Ontario”, “serviceLocation” => “atBusiness”, “streetAddress” => “1450 Islington Ave”}} to 500 response

I’m not sure what you’re trying to do, but your “json string” is no json string.
It’s just an elixir map and you can’t parse that with Jason.decode!

{
  "ZIPcodePostalCode": "M9B 2k7",
  "appointmentName": "fssdf",
   ...
}

Sorry, I had to reedit the post, but my json string seems to be valid. It’s coming from a frontend application, I’ve also used https://jsonlint.com to verify the json string and it seems to be valid.

This error is not produced by Jason library. Provided JSON string was successfully decoded, and the error was happened in other levels of your application.

3 Likes