{"action":"created","issue":{"url":"https://api.github.com/repos/strongloop/loopback/issues/445","labels_url":"https://api.github.com/repos/strongloop/loopback/issues/445/labels{/name}","comments_url":"https://api.github.com/repos/strongloop/loopback/issues/445/comments","events_url":"https://api.github.com/repos/strongloop/loopback/issues/445/events","html_url":"https://github.com/strongloop/loopback/issues/445","id":39640850,"number":445,"title":"Any chance of supporting jsonapi.org?","user":{"login":"conrad-vanl","id":103927,"avatar_url":"https://avatars.githubusercontent.com/u/103927?v=3","gravatar_id":"","url":"https://api.github.com/users/conrad-vanl","html_url":"https://github.com/conrad-vanl","followers_url":"https://api.github.com/users/conrad-vanl/followers","following_url":"https://api.github.com/users/conrad-vanl/following{/other_user}","gists_url":"https://api.github.com/users/conrad-vanl/gists{/gist_id}","starred_url":"https://api.github.com/users/conrad-vanl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/conrad-vanl/subscriptions","organizations_url":"https://api.github.com/users/conrad-vanl/orgs","repos_url":"https://api.github.com/users/conrad-vanl/repos","events_url":"https://api.github.com/users/conrad-vanl/events{/privacy}","received_events_url":"https://api.github.com/users/conrad-vanl/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/strongloop/loopback/labels/feature","name":"feature","color":"bfe5bf"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":43,"created_at":"2014-08-06T16:41:28Z","updated_at":"2015-09-26T19:13:05Z","closed_at":null,"body":"Is there any way, or plans, to configure how JSON responses (and therefore requests) are serialized? For instance, it would be very nice to support a standard, such as http://jsonapi.org/ so that clients can take advantage of generalized tooling. Looking at the current API, it would appear to me the biggest thing would be for models to be serialized in root objects...\r\n\r\nThis:\r\n\r\n````json\r\n{\r\n   \"user\": {\r\n      \"id\": \"...\",\r\n      \"name\": \"Conrad\"\r\n   }\r\n}\r\n````\r\n\r\nAs opposed to:\r\n\r\n````json\r\n{\r\n   \"id\": \"...\",\r\n   \"name\": \"Conrad\"\r\n}\r\n````\r\n\r\nThere would also be other considerations in how associations and relations are serialized."},"comment":{"url":"https://api.github.com/repos/strongloop/loopback/issues/comments/143480248","html_url":"https://github.com/strongloop/loopback/issues/445#issuecomment-143480248","issue_url":"https://api.github.com/repos/strongloop/loopback/issues/445","id":143480248,"user":{"login":"digitalsadhu","id":1177098,"avatar_url":"https://avatars.githubusercontent.com/u/1177098?v=3","gravatar_id":"","url":"https://api.github.com/users/digitalsadhu","html_url":"https://github.com/digitalsadhu","followers_url":"https://api.github.com/users/digitalsadhu/followers","following_url":"https://api.github.com/users/digitalsadhu/following{/other_user}","gists_url":"https://api.github.com/users/digitalsadhu/gists{/gist_id}","starred_url":"https://api.github.com/users/digitalsadhu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/digitalsadhu/subscriptions","organizations_url":"https://api.github.com/users/digitalsadhu/orgs","repos_url":"https://api.github.com/users/digitalsadhu/repos","events_url":"https://api.github.com/users/digitalsadhu/events{/privacy}","received_events_url":"https://api.github.com/users/digitalsadhu/received_events","type":"User","site_admin":false},"created_at":"2015-09-26T19:13:05Z","updated_at":"2015-09-26T19:13:05Z","body":"@bajtos It looks to me like at present because the relationship methods are recreated on the fly each time .methods() is called, the only way to do this right now is to overwrite the relationship methods on the Model class in loopback since thats where the remote method definitions are. See:\r\n\r\nhttps://github.com/strongloop/loopback/blob/master/lib/model.js#L485-L492\r\n\r\nThe `define` method is passed in from strong remotings `sharedClass` but the definitions are hard coded in methods like `Model.hasOneRemoting` and its from there that the remote methods are created each time you call methods()"}}