sdk_python icon indicating copy to clipboard operation
sdk_python copied to clipboard

Extract JsonAdapter as own library

Open PJUllrich opened this issue 8 years ago • 3 comments

Your functionality on de- & serialising (especially nested) JSON data to Python classes is pretty neat and actually high in demand in the Python community at the moment.

Until now, JSONPickle is mostly the library of choice when de/serialising nested JSON data from and to Python objects, but "pickled" JSON Data (with Pickle serialised Python Objects) can only be deserialised with the same methods as with which they were serialised. Therefore, nested JSON data received from somewhere else cannot be deserialised without knowing how it was serialised.

Your JSONAdapter class seems to be able to do just that without knowing how the data was serialised. Given the need for such functionality in the Python community, I'd like to propose that you extract this functionality into a separate library and preferably put it on PyPi.

PJUllrich avatar Aug 02 '17 14:08 PJUllrich

This is indeed a good and valid point 👍. We'll look into this and see if we can manage to achieve this in one of the next releases. But first we must get the whole SDK on PyPi first 😋.

OGKevin avatar Aug 02 '17 14:08 OGKevin

@PJUllrich That's a great idea, thank you!

Our library, however, does know about the types of the data received: it reads those from the docstrings of the models.

So, basically it does know which object the data represents (initially we pass the type in the method call). The rest is just looping around the nested structure and parsing the types of everything from the docstrings of Python :)

dnl-blkv avatar Aug 02 '17 14:08 dnl-blkv

@dnl-blkv hmm that's a bummer indeed. Well a bummer because to have such functionality would be pretty awesome ;-) . However, it's also been a while since I looked into this de/serialization issue in Python. I'll do some research and come back to this.

PJUllrich avatar Aug 03 '17 16:08 PJUllrich