JSON.stringify (Javascript) and json.dumps (Python) not equivalent on a list?

JSON.stringify (Javascript) and json.dumps (Python) not equivalent on a list?

The difference is that json.dumps applies some minor pretty-printing by default but JSON.stringify does not.

To remove all whitespace, like JSON.stringify, you need to specify the separators.

json_mylist = json.dumps(mylist, separators=(,, :))

JSON.stringify (Javascript) and json.dumps (Python) not equivalent on a list?

Leave a Reply

Your email address will not be published. Required fields are marked *