Open al2o3cr opened 3 years ago
Before 0.9.0, a response like ExTwilio.Lookup.PhoneNumber had string keys in child maps like carrier, because Poison doesn't convert them to atoms:
ExTwilio.Lookup.PhoneNumber
carrier
iex> resp_str = "{\"add_ons\":null,\"caller_name\":null,\"carrier\":{\"name\":\"foo\",\"type\":\"bar\"},\"country_code\":\"US\",\"national_format\":\"blergh\",\"phone_number\":\"1234\",\"url\":\"abcd\"}" iex> Poison.decode!(resp_str, as: ExTwilio.Lookup.PhoneNumber.__struct__) %ExTwilio.Lookup.PhoneNumber{ add_ons: nil, caller_name: nil, carrier: %{"name" => "foo", "type" => "bar"}, country_code: "US", national_format: "blergh", phone_number: "1234", url: "abcd" }
but the corresponding Jason code does:
Jason
iex> struct(ExTwilio.Lookup.PhoneNumber, Jason.decode!(resp_str, keys: :atoms)) %ExTwilio.Lookup.PhoneNumber{ add_ons: nil, caller_name: nil, carrier: %{name: "foo", type: "bar"}, country_code: "US", national_format: "blergh", phone_number: "1234", url: "abcd" }
This should be called out in the changelog.
EDIT: removed unroutable private IP address from the example
+1 to this, this just bit me too
Before 0.9.0, a response like
ExTwilio.Lookup.PhoneNumber
had string keys in child maps likecarrier
, because Poison doesn't convert them to atoms:but the corresponding
Jason
code does:This should be called out in the changelog.
EDIT: removed unroutable private IP address from the example