ramonhagenaars / jsons

🐍 A Python lib for (de)serializing Python objects to/from JSON
https://jsons.readthedocs.io
MIT License
289 stars 41 forks source link

output contains single quotes not double quotes #94

Closed Bengreen closed 4 years ago

Bengreen commented 4 years ago

I have been trying out the jsons library and it looks great. But one thing is confusing me. The JSON returned is not true json as it is using single quotes rather than double quotes. I have been able to get it to return double quotes (e.g. jsons.dumps(myObject) But out of the box jsons.dump(myObject) is returning single quotes and using JsonSerializable , myObject.json uses single quotes.

I have always used JSON with double quotes and using single quotes has been problematic and not in line with the standard ... OR Am I missing something here ?

Bengreen commented 4 years ago

OK... I think I got this now. Am I correct that : jsons.dump will serialise to a python object which can then be serialised to a string (which is the json string I am expecting with the double quotes, etc).

ramonhagenaars commented 4 years ago

Hi @Bengreen. You're right: jsons.dump will dump a Python object to a dict (which is usually represented with single quotes). jsons.dumps will dump to a json string object with double quotes (formally the correct quote to use in the json format).