Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0.9.0 changes the behavior for nested data #148

Open
al2o3cr opened this issue Mar 9, 2021 · 1 comment
Open

0.9.0 changes the behavior for nested data #148

al2o3cr opened this issue Mar 9, 2021 · 1 comment
Labels

Comments

@al2o3cr
Copy link

al2o3cr commented Mar 9, 2021

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:

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:

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

@srcrip
Copy link

srcrip commented Jan 24, 2023

+1 to this, this just bit me too

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants