Store original JSON response for objects and expose it for document-oriented storage #144

ptwobrussell opened this Issue Mar 7, 2013 · 1 comment


None yet

2 participants


I'd like to be able to serialize a GithubObject and get back the original JSON that was used to initially construct it for purposes of serializing out to a document oriented store like MongoDB where this representation would be a natural (and highly portable) fit for storage. From looking at how objects are constructed, it seems as though it would be pretty trivial to keep around the JSON and expose it as necessary as opposed to just discarding it.

Perhaps __str__ could return the readable JSON representation and __repr__ could contain what currently happens from __str__ (the unambiguous object with its address)?

If there are concerns over memory, perhaps this could be a configurable option?

At any rate, I could help put together the patch but would first like to get your thoughts and whether or not you're open to merging in such a pull request

jacquev6 commented Mar 7, 2013

This seems a good idea. Using all the data returned by Github will preserve attributes that may have been added by Github, but not yet exposed by PyGithub.

Here are some things that must be taken care of:

  • I would rather not expose the json string, but the structured (deserialized) data:
    • This would be usable in more cases (serialization in other formats for example).
    • For objects constructed from a json list, the json representation of the object itself is a substring of the returned string, and it will not be easy to extract it.
  • lazy completion (described here: #139 (comment)) : the data is not the same before and after completion. So accessing this data should trigger the completion, as done for all other attributes.
  • we also need a way to construct a GithubObject from the exposed data, for deserialization.
@jacquev6 jacquev6 was assigned Mar 7, 2013
@jacquev6 jacquev6 closed this Mar 21, 2013
@ptwobrussell ptwobrussell added the v1 label Mar 2, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment