Closed GCorbel closed 8 years ago
The code stops at this line. payload['data']
gives nil but payload[:data]
works.
Calling deep_stringify_keys
works. It sill don't work for parameters because I can't apply this function, it's done when the action is triggered.
I think this will be fixed by https://github.com/rails-api/active_model_serializers/pull/1645 cc @remear
I gave a try with the current code of this PR and its not resolved yet.
I tried to do a fork and I added document.deep_stringify_keys!
on the parse method. Now, I have {:title=>"Title 1", :date=>"2015-12-20", :id=>1}
.
I don't understand how parameters are parsed.
When I do a request with this data {"data":{"attributes":{"allow_multiple_payment":false},"type":"settings"}}
, I have this kind of params Parameters: {"fomat"=>:json, "setting"=>{}}
.
For what it's worth, we have labeled deserialization as experimental
On Sat, Apr 2, 2016 at 2:49 PM Guirec Corbel notifications@github.com wrote:
I tried to do a fork and I added document.deep_stringify_keys! on the parse method. Now, I have {:title=>"Title 1", :date=>"2015-12-20", :id=>1}.
I don't understand how parameters are parsed. When I do a request with this data {"data":{"attributes":{"allow_multiple_payment":false},"type":"settings"}}, I have this kind of params Parameters: {"fomat"=>:json, "setting"=>{}}.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/rails-api/active_model_serializers/issues/1640#issuecomment-204789189
The jsonapi_parse
method is intended for deserializing JSON hashes, for which the keys will always be strings.
@GCorbel I just fixed the doc according to my previous comment. Closing this, thank you for spotting it!
Expected behavior vs actual behavior
With the current master branch, I tried to deserialize like in the doc with a simple copy/paste. Instead of
I have this :
Steps to reproduce
(e.g., detailed walkthrough, runnable script, example application)
Copy and paste from the doc
Environment
Integrated application and version (e.g., Rails, Grape, etc):
Rails 5.0.0.beta2