Tools, FAQ, Tutorials:
Dumping JSON Output to File
How to dump (or encode, serialize) a Python object into file or an output stream as a JSON string using json.dump()?
✍: FYIcenter.com
json.dump(o,fp,...) function performs the same job as json.dumps(o,...) except that it directs the JSON string to the output stream of a given file pointer.
Here is a Python example that generates a pretty formatted JSON string with property keys sorted:
>>> import json >>> import sys >>> l = ['foo', {'bar': ('baz', None, 1.0, {"c": 0, "b": 0, "a": 0})}] >>> json.dump(l, sys.stdout, indent=3, sort_keys=True) [ "foo", { "bar": [ "baz", null, 1.0, { "a": 0, "b": 0, "c": 0 } ] } ]>>>
⇒ What Is json.JSONEncoder Class
⇐ Generating JSON Strings in Pretty Format
2018-10-08, 1399🔥, 0💬
Popular Posts:
Where to find tutorials on Using Azure API Management Publisher Dashboard? Here is a list of tutoria...
Where to find tutorials on RSS specifications? I want to learn it to describe my API services. Here ...
Can You Specify the "new line" Character in Single-Quoted Strings? You can not specify the "new line...
What Is HTML? HTML (HyperText Markup Language) is the standard markup language for creating Web page...
How To Read Data from Keyboard (Standard Input) in PHP? If you want to read data from the standard i...