Answers for "python json dump to object"

1

python json dump format

>>> import json
>>>
>>> your_json = '["foo", {"bar":["baz", null, 1.0, 2]}]'
>>> parsed = json.loads(your_json)
>>> print(json.dumps(parsed, indent=4, sort_keys=True))
[
    "foo", 
    {
        "bar": [
            "baz", 
            null, 
            1.0, 
            2
        ]
    }
]
Posted by: Guest on January-12-2021
6

python json dump to file

import json
with open('data.json', 'w') as f:
    json.dump(data, f)
Posted by: Guest on August-15-2020
4

python json.dumps pretty print

json.dumps(x, indent=4)
Posted by: Guest on September-23-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language