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, 1473🔥, 0💬
Popular Posts:
How to use the "rewrite-uri" Policy Statement for an Azure API service operation? The "rewrite-uri" ...
How to create the Hello-3.0.epub package? I have all required files to create Hello-3.0.epub. To cre...
How to use the "@(...)" expression in Azure API Policy? The "@(...)" expression in Azure API Policy ...
How To Loop through an Array without Using "foreach" in PHP? PHP offers the following functions to a...
How to create Hello-3.1.epub with WinRAR? I have all required files to create Hello-3.1.epub. To cre...