{"action":"created","issue":{"url":"https://api.github.com/repos/danivek/json-api-serializer/issues/5","repository_url":"https://api.github.com/repos/danivek/json-api-serializer","labels_url":"https://api.github.com/repos/danivek/json-api-serializer/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/danivek/json-api-serializer/issues/5/comments","events_url":"https://api.github.com/repos/danivek/json-api-serializer/issues/5/events","html_url":"https://github.com/danivek/json-api-serializer/issues/5","id":164531568,"number":5,"title":"Attributes becomes an object to id when related","user":{"login":"jmillegard","id":3763437,"avatar_url":"https://avatars.githubusercontent.com/u/3763437?v=3","gravatar_id":"","url":"https://api.github.com/users/jmillegard","html_url":"https://github.com/jmillegard","followers_url":"https://api.github.com/users/jmillegard/followers","following_url":"https://api.github.com/users/jmillegard/following{/other_user}","gists_url":"https://api.github.com/users/jmillegard/gists{/gist_id}","starred_url":"https://api.github.com/users/jmillegard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmillegard/subscriptions","organizations_url":"https://api.github.com/users/jmillegard/orgs","repos_url":"https://api.github.com/users/jmillegard/repos","events_url":"https://api.github.com/users/jmillegard/events{/privacy}","received_events_url":"https://api.github.com/users/jmillegard/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-07-08T13:31:38Z","updated_at":"2016-07-08T14:07:50Z","closed_at":"2016-07-08T14:07:50Z","body":"Thanks for this great serializer! Works great for my needs except from this one big thing:\r\n\r\nWhen I have data like this:\r\n```javascript\r\n{\r\n    \"id\": 246,\r\n    \"parent\": null,\r\n    \"document\": 1,\r\n    \"product\": null,\r\n    \"name\": \"Engelska\",\r\n    \"type\": \"products\",\r\n    \"template\": null,\r\n    \"metadata\": null,\r\n    \"sort\": null,\r\n    \"status\": null,\r\n    \"created\": \"2016-07-07T11:52:16.237Z\",\r\n    \"updated\": null,\r\n    \"tags\": [\r\n        {\r\n            \"id\": 6,\r\n            \"parent\": null,\r\n            \"name\": \"Gymnasiet\",\r\n            \"slug\": \"gymnasiet\",\r\n            \"displayname\": \"Gymnasiet\",\r\n            \"image\": null,\r\n            \"metadata\": null,\r\n            \"type\": \"age_groups\",\r\n            \"created\": \"2016-07-07T11:27:35.386Z\",\r\n            \"updated\": null\r\n        },\r\n        {\r\n            \"id\": 18,\r\n            \"parent\": null,\r\n            \"name\": \"Testkategori\",\r\n            \"slug\": null,\r\n            \"displayname\": null,\r\n            \"image\": null,\r\n            \"metadata\": null,\r\n            \"type\": null,\r\n            \"created\": \"2016-07-08T11:32:05.471Z\",\r\n            \"updated\": null\r\n        }\r\n    ]\r\n}\r\n```\r\n\r\nand my serializer looks lite this:\r\n\r\n```javascript\r\nSerializer.register('node', {\r\n        \r\n  id: 'id',\r\n  topLevelLinks: { \r\n    self: 'http://localhost:3000/api/v1/nodes' \r\n  },\r\n  links: { \r\n    self: function(data) {\r\n      return 'http://localhost:3000/api/v1/nodes/' + data.id;\r\n    }\r\n  },\r\n  relationships: {\r\n    tags: {\r\n      type: 'tag', \r\n    }\r\n  },\r\n  convertCase: \"kebab-case\"        \r\n});\r\n    \r\nSerializer.register('tag', { \r\n  id: 'id',\r\n  convertCase: \"kebab-case\",\r\n});\r\n\r\n```\r\n\r\nThe results becomes quite awkward:\r\n\r\n```javascript\r\n{\r\n    \"jsonapi\": {\r\n        \"version\": \"1.0\"\r\n    },\r\n    \"links\": {\r\n        \"self\": \"http://localhost:3000/api/v1/nodes\"\r\n    },\r\n    \"data\": {\r\n        \"type\": \"nodes\",\r\n        \"id\": 246,\r\n        \"attributes\": {\r\n            \"parent\": null,\r\n            \"document\": 1,\r\n            \"product\": null,\r\n            \"name\": \"Engelska\",\r\n            \"type\": \"products\",\r\n            \"template\": null,\r\n            \"metadata\": null,\r\n            \"sort\": null,\r\n            \"status\": null,\r\n            \"created\": \"2016-07-07T11:52:16.237Z\",\r\n            \"updated\": null\r\n        },\r\n        \"relationships\": {\r\n            \"tags\": {\r\n                \"data\": [\r\n                    {\r\n                        \"type\": \"tag\",\r\n                        \"id\": {\r\n                            \"id\": 6,\r\n                            \"parent\": null,\r\n                            \"name\": \"Gymnasiet\",\r\n                            \"slug\": \"gymnasiet\",\r\n                            \"displayname\": \"Gymnasiet\",\r\n                            \"image\": null,\r\n                            \"metadata\": null,\r\n                            \"type\": \"age_groups\",\r\n                            \"created\": \"2016-07-07T11:27:35.386Z\",\r\n                            \"updated\": null\r\n                        }\r\n                    },\r\n                    {\r\n                        \"type\": \"tag\",\r\n                        \"id\": {\r\n                            \"id\": 18,\r\n                            \"parent\": null,\r\n                            \"name\": \"Testkategori\",\r\n                            \"slug\": null,\r\n                            \"displayname\": null,\r\n                            \"image\": null,\r\n                            \"metadata\": null,\r\n                            \"type\": null,\r\n                            \"created\": \"2016-07-08T11:32:05.471Z\",\r\n                            \"updated\": null\r\n                        }\r\n                    }\r\n                ]\r\n            }\r\n        },\r\n        \"links\": {\r\n            \"self\": \"http://localhost:3000/api/v1/nodes/246\"\r\n        }\r\n    }\r\n}\r\n\r\n```\r\n\r\nAs you can see, the tag object becomes appended to the ID, and the tags doesnt get in the included key.\r\n\r\nAny idea of what can cause this?"},"comment":{"url":"https://api.github.com/repos/danivek/json-api-serializer/issues/comments/231368753","html_url":"https://github.com/danivek/json-api-serializer/issues/5#issuecomment-231368753","issue_url":"https://api.github.com/repos/danivek/json-api-serializer/issues/5","id":231368753,"user":{"login":"jmillegard","id":3763437,"avatar_url":"https://avatars.githubusercontent.com/u/3763437?v=3","gravatar_id":"","url":"https://api.github.com/users/jmillegard","html_url":"https://github.com/jmillegard","followers_url":"https://api.github.com/users/jmillegard/followers","following_url":"https://api.github.com/users/jmillegard/following{/other_user}","gists_url":"https://api.github.com/users/jmillegard/gists{/gist_id}","starred_url":"https://api.github.com/users/jmillegard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmillegard/subscriptions","organizations_url":"https://api.github.com/users/jmillegard/orgs","repos_url":"https://api.github.com/users/jmillegard/repos","events_url":"https://api.github.com/users/jmillegard/events{/privacy}","received_events_url":"https://api.github.com/users/jmillegard/received_events","type":"User","site_admin":false},"created_at":"2016-07-08T14:07:50Z","updated_at":"2016-07-08T14:07:50Z","body":"NWM,\r\n\r\nSeems like something was wrong with my \"tags\" object coming from postgresql. When I stringified and JSON.parsed my tag-data it worked as expected."}}
{"actor":{"display_login":"jmillegard"}}