{"action":"created","issue":{"url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/323","repository_url":"https://api.github.com/repos/SatelliteQE/nailgun","labels_url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/323/labels{/name}","comments_url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/323/comments","events_url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/323/events","html_url":"https://github.com/SatelliteQE/nailgun/issues/323","id":180719785,"number":323,"title":"Make entities JSON Serializable","user":{"login":"rochacbruno","id":458654,"avatar_url":"https://avatars.githubusercontent.com/u/458654?v=3","gravatar_id":"","url":"https://api.github.com/users/rochacbruno","html_url":"https://github.com/rochacbruno","followers_url":"https://api.github.com/users/rochacbruno/followers","following_url":"https://api.github.com/users/rochacbruno/following{/other_user}","gists_url":"https://api.github.com/users/rochacbruno/gists{/gist_id}","starred_url":"https://api.github.com/users/rochacbruno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rochacbruno/subscriptions","organizations_url":"https://api.github.com/users/rochacbruno/orgs","repos_url":"https://api.github.com/users/rochacbruno/repos","events_url":"https://api.github.com/users/rochacbruno/events{/privacy}","received_events_url":"https://api.github.com/users/rochacbruno/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-10-03T19:05:11Z","updated_at":"2016-10-04T17:38:23Z","closed_at":null,"body":"in #321 @ehelms discovered that nailgun entities are not JSONSerializable.\r\n\r\nI made a simple test.\r\n\r\n```python\r\nIn [1]: from nailgun.entities import Organization\r\nIn [2]: org = Organization()\r\nIn [3]: import json\r\nIn [4]: json.dumps(org)\r\n/usr/lib64/python2.7/json/encoder.pyc in default(self, o)\r\n    182 \r\n    183         \"\"\"\r\n--> 184         raise TypeError(repr(o) + \" is not JSON serializable\")\r\n    185 \r\n    186     def encode(self, o):\r\n\r\nTypeError: Organization(nailgun.config.ServerConfig(....)) is not JSON serializable\r\n```\r\n\r\nThat happens because `__repr__` of entities are not returning values that default JSON Decoder is able to parse, also there is no `to_json` method and no recursive traversing of nested entities.\r\n\r\nWe can develop all of this builtin, but looks like a lot of work, so:\r\n\r\nI am suggesting to use Marshmallow[1] as it is a known and stable existing library to give  Schema Validation and Serialization to nailgun.\r\n\r\n[1] https://marshmallow.readthedocs.io/en/latest/\r\n\r\nIf including one more external dependency is a problem we can start developing builtin functionality.\r\n\r\nNOTES:\r\n\r\n1. That feature looks important in order to make **nailgun** working out of the box with Ansible\r\n2. We can make it in the way the method `to_json` needs to be explicitly called or provide `nailgun.JSONDecoder` to be used when dumping or try to automate everything.\r\n3. It can be implemented as a `nailgun_plugin` so a different project `pip install nailgun-json` and when that thing is installed `json.dumps(entity)` will automatically give a json relying on Marshmallow.\r\n\r\n\r\n  "},"comment":{"url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/comments/251458346","html_url":"https://github.com/SatelliteQE/nailgun/issues/323#issuecomment-251458346","issue_url":"https://api.github.com/repos/SatelliteQE/nailgun/issues/323","id":251458346,"user":{"login":"JacobCallahan","id":6618303,"avatar_url":"https://avatars.githubusercontent.com/u/6618303?v=3","gravatar_id":"","url":"https://api.github.com/users/JacobCallahan","html_url":"https://github.com/JacobCallahan","followers_url":"https://api.github.com/users/JacobCallahan/followers","following_url":"https://api.github.com/users/JacobCallahan/following{/other_user}","gists_url":"https://api.github.com/users/JacobCallahan/gists{/gist_id}","starred_url":"https://api.github.com/users/JacobCallahan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JacobCallahan/subscriptions","organizations_url":"https://api.github.com/users/JacobCallahan/orgs","repos_url":"https://api.github.com/users/JacobCallahan/repos","events_url":"https://api.github.com/users/JacobCallahan/events{/privacy}","received_events_url":"https://api.github.com/users/JacobCallahan/received_events","type":"User","site_admin":false},"created_at":"2016-10-04T17:38:23Z","updated_at":"2016-10-04T17:38:23Z","body":"@elyezer I'm sure there very well is a solution within Nailgun. I'm just trying to push my attrs agenda!"}}
{"actor":{"display_login":"JacobCallahan"}}