Open w3villa-amit opened 4 years ago
It strictly follows JSON:API formatting. https://jsonapi.org/
Is there any way to remove the attributes and relationship key and transform them into a single merged hash.
@w3villa-amit You can try using
.as_json['data'].map{ |v| v['attributes'] }
Or using a custom method over it to generate expected response.
However, use of this gem encourages the response of only the latest JSON:API formatting and I suggest you make changes on the client-side to consume such response.
Hello Everyone please help me I am using the Active model serializer in my project as i saw the the fast json API serializer is fast from the Active model serializer but i am stuck during customisation of the json response Here is my previous JSON -: {id: 3129, status_name: "To-do", name: "hkjhkSASFSFSDAFASDF", owner_id: 0, status_id: 42, points: null,…} id: 3129 status_name: "To-do" name: "hkjhkSASFSFSDAFASDF" owner_id: 0 status_id: 42 points: null date: "Tuesday, 04 Feb 2020" project_story_id: 141 index: 0 seen: false tags: [] owner: null categories: [] story_categories: []
And here is the Fast Json Api response -: data: [{id: "3129", type: "story_light",…}, {id: "2987", type: "story_light",…},…] 0: {id: "3129", type: "story_light",…} id: "3129" type: "story_light" attributes: {id: 3129, status_name: "To-do", name: "hkjhkSASFSFSDAFASDF", owner_id: 0, status_id: 42, points: null,…} id: 3129 status_name: "To-do" name: "hkjhkSASFSFSDAFASDF" owner_id: 0 status_id: 42 points: null date: "Tuesday, 04 Feb 2020" project_story_id: 141 index: 0 seen: false relationships: {tags: {data: []}, owner: {data: {id: "0", type: "owner"}}, categories: {data: []},…} tags: {data: []} owner: {data: {id: "0", type: "owner"}} categories: {data: []} story_categories: {data: []}
Please Help!