1

I use Python 3.7.1.

What I am looking for is to save transformed/treated object in a file, then open this file in a any text editor.

JSON is not what I am looking for. "JSON is a text serialization format (it outputs unicode text, although most of the time it is then encoded to utf-8), while pickle is a binary serialization format". It looks perfect but my problem is JSON has no reason to support a namedtuple object. As far as I know it supports dict,list,and so on, but not this kind of objects.

Besides, as you read pickle makes binary serialization and this is unreadable by any text editor.

So, I want to know if there are other ways of human readable serialization of python's object, hoping this is not to complicated to implement.

AvyWam
  • 890
  • 8
  • 28
  • I think this would help https://stackoverflow.com/questions/408866/python-human-readable-object-serialization – Rahim Sep 14 '19 at 12:07
  • More hints : https://stackoverflow.com/questions/15476983/deserialize-a-json-string-to-an-object-in-python and https://stackoverflow.com/questions/5906831/serializing-a-python-namedtuple-to-json – PilouPili Sep 14 '19 at 12:13
  • @PilouPili Thank you. The [library shown](https://pypi.org/project/jsonplus/) in the second topic seems alright. I gonna test it. – AvyWam Sep 14 '19 at 12:48
  • Pleasure. If you find something generic and that does the job you can answer your own question to help the community. – PilouPili Sep 14 '19 at 12:50

0 Answers0