{"action":"created","issue":{"url":"https://api.github.com/repos/jlafon/PynamoDB/issues/152","repository_url":"https://api.github.com/repos/jlafon/PynamoDB","labels_url":"https://api.github.com/repos/jlafon/PynamoDB/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/jlafon/PynamoDB/issues/152/comments","events_url":"https://api.github.com/repos/jlafon/PynamoDB/issues/152/events","html_url":"https://github.com/jlafon/PynamoDB/issues/152","id":171911573,"number":152,"title":"Convert model instance to JSON","user":{"login":"ccverak","id":1001834,"avatar_url":"https://avatars.githubusercontent.com/u/1001834?v=3","gravatar_id":"","url":"https://api.github.com/users/ccverak","html_url":"https://github.com/ccverak","followers_url":"https://api.github.com/users/ccverak/followers","following_url":"https://api.github.com/users/ccverak/following{/other_user}","gists_url":"https://api.github.com/users/ccverak/gists{/gist_id}","starred_url":"https://api.github.com/users/ccverak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ccverak/subscriptions","organizations_url":"https://api.github.com/users/ccverak/orgs","repos_url":"https://api.github.com/users/ccverak/repos","events_url":"https://api.github.com/users/ccverak/events{/privacy}","received_events_url":"https://api.github.com/users/ccverak/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-08-18T14:14:55Z","updated_at":"2016-12-19T15:23:19Z","closed_at":null,"body":"Is there a way to convert a model instance to JSON??, I'm getting `<Obj> is not JSON serializable` when trying to serialize with JSON module\n"},"comment":{"url":"https://api.github.com/repos/jlafon/PynamoDB/issues/comments/267991119","html_url":"https://github.com/jlafon/PynamoDB/issues/152#issuecomment-267991119","issue_url":"https://api.github.com/repos/jlafon/PynamoDB/issues/152","id":267991119,"user":{"login":"jdno","id":865550,"avatar_url":"https://avatars.githubusercontent.com/u/865550?v=3","gravatar_id":"","url":"https://api.github.com/users/jdno","html_url":"https://github.com/jdno","followers_url":"https://api.github.com/users/jdno/followers","following_url":"https://api.github.com/users/jdno/following{/other_user}","gists_url":"https://api.github.com/users/jdno/gists{/gist_id}","starred_url":"https://api.github.com/users/jdno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jdno/subscriptions","organizations_url":"https://api.github.com/users/jdno/orgs","repos_url":"https://api.github.com/users/jdno/repos","events_url":"https://api.github.com/users/jdno/events{/privacy}","received_events_url":"https://api.github.com/users/jdno/received_events","type":"User","site_admin":false},"created_at":"2016-12-19T15:23:19Z","updated_at":"2016-12-19T15:23:19Z","body":"As @csimmons0 said in his pull request: `_serialize()` is too close to the data representation in DynamoDB and thus not suitable for (my) APIs. Besides, `_serialize()` looks like a  \"private\" method and should not be used by third-party code.\r\n\r\nI agree that we need a method that produces a dict or JSON representation of the model object that abstracts from the underlying data representation. For example, here is what I get when I serialize my object with `_serialize()`:\r\n\r\n```\r\n{\r\n  'attributes': {\r\n    'owner': {'S': u'test|12345678'},\r\n    'updated': {'S': u'2016-12-19T14:52:32.140080+00:00'},\r\n    'name': {'S': u'Test Organization'},\r\n    'members': {'SS': [u'test|12345678']},\r\n    'created': {'S': u'2016-12-19T14:52:32.140106+00:00'}\r\n  },\r\n  'HASH': u'59fc2bcd-230d-427c-ae9f-9834bf29fc8a'\r\n}\r\n```\r\n\r\nHowever, the following is what I need to pass it along to my user-facing API:\r\n\r\n```python\r\n{\r\n  'id': '59fc2bcd-230d-427c-ae9f-9834bf29fc8a',\r\n  'name': 'Test Organization',\r\n  'owner': 'test|12345678',\r\n  'members': [\r\n    'test|12345678'\r\n  ],\r\n  'created': '2016-12-19T14:52:32.140106+00:00',\r\n  'updated': '2016-12-19T14:52:32.140106+00:00'\r\n}\r\n```\r\n\r\nWould be great to get some feedback on this from @jlafon so that we can merge (or work on) #156."}}
{"actor":{"display_login":"jdno"}}