Description
Looking at https://github.com/JsonApiClient/json_api_client/pull/386/files, I see that there's shift towards using HashWithIndiferentAccess, however, this change causes a wrong serialization when calling as_json_api
. Which is causing a lot of tests to break on my end. Here's an example:
The previous symbolize_keys
approach would serialize like this:
resource.as_json_api
{"type"=>"resources", "relationships"=>{"location"=>{"data"=>{"type"=>"locations", "id"=>"1"}}}, "attributes"=>{"arrival-time"=>"...", "full-name"=>"a full name", "email"=>nil, "user-data"=>[{"field"=>"color", "value"=>"blue"}], "private-notes"=>nil, "guests"=>nil, "phone"=>nil}}
but with the new with_indiferent_access
approach it serializes like this:
resource.as_json_api
{"type"=>"resources", "relationships"=>{"location"=>{"data"=>{"type"=>"locations", "id"=>"1"}}}, "attributes"=>{"arrival-time"=>"...", "full-name"=>"a full name", "email"=>nil, "user-data"=>[{"field"=>"color", "value"=>"blue"}], "private-notes"=>nil, "additional-guests"=>nil, "phone"=>nil, "location"=>#<Models::Location:@attributes={"type"=>"locations", "id"=>"1", "address_line_one"=>nil, "address_line_two"=>nil}>}}
It is adding location
as an attribute and set it equals to the value of to_s
. which is derived from using with_indiferent_access
.
These results I got from getting 1.20.0 and manually reverting the symbolize keys change.
Would really appreciate any guidance here, although it seems that the version 1.19.0 added some unexpected behavior.
Thanks in advance for any help/comments