From c46944dee338ee3fbee69e21e2c7909570d0570e Mon Sep 17 00:00:00 2001 From: Nicholas Date: Mon, 29 Jun 2020 22:50:04 +0800 Subject: [PATCH 1/2] Use string keys in example for Deserialization fixes #2384 --- .../adapter/json_api/deserialization.rb | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/lib/active_model_serializers/adapter/json_api/deserialization.rb b/lib/active_model_serializers/adapter/json_api/deserialization.rb index 1af20d94a..b741a75ac 100644 --- a/lib/active_model_serializers/adapter/json_api/deserialization.rb +++ b/lib/active_model_serializers/adapter/json_api/deserialization.rb @@ -25,30 +25,30 @@ module Deserialization # # @example # document = { - # data: { - # id: 1, - # type: 'post', - # attributes: { - # title: 'Title 1', - # date: '2015-12-20' + # 'data' => { + # 'id' => 1, + # 'type' => 'post', + # 'attributes' => { + # 'title' => 'Title 1', + # 'date' => '2015-12-20' # }, - # associations: { - # author: { - # data: { - # type: 'user', - # id: 2 + # 'relationships' => { + # 'author' => { + # 'data' => { + # 'type' => 'user', + # 'id' => 2 # } # }, - # second_author: { - # data: nil + # 'second_author' => { + # 'data' => nil # }, - # comments: { - # data: [{ - # type: 'comment', - # id: 3 + # 'comments' => { + # 'data' => [{ + # 'type' => 'comment', + # 'id' => 3 # },{ - # type: 'comment', - # id: 4 + # 'type' => 'comment', + # 'id' => 4 # }] # } # } From a60d5dee5680986f3fec18ec3469abf1c49debe9 Mon Sep 17 00:00:00 2001 From: Nicholas Koh Date: Mon, 29 Jun 2020 23:21:56 +0800 Subject: [PATCH 2/2] Update examples for Deserialization --- .../adapter/json_api/deserialization.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/active_model_serializers/adapter/json_api/deserialization.rb b/lib/active_model_serializers/adapter/json_api/deserialization.rb index b741a75ac..ce8fbbc5a 100644 --- a/lib/active_model_serializers/adapter/json_api/deserialization.rb +++ b/lib/active_model_serializers/adapter/json_api/deserialization.rb @@ -59,6 +59,7 @@ module Deserialization # # { # # title: 'Title 1', # # date: '2015-12-20', + # # id: 1, # # author_id: 2, # # second_author_id: nil # # comment_ids: [3, 4] @@ -70,8 +71,8 @@ module Deserialization # # { # # title: 'Title 1', # # published_at: '2015-12-20', - # # author_id: '2', - # # author_type: 'people' + # # author_id: 2, + # # author_type: 'User' # # } # def parse!(document, options = {})