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, 1389🔥, 0💬
Popular Posts:
How To Convert a Character to an ASCII Value? If you want to convert characters to ASCII values, you...
How to use "json-to-xml" Azure API Policy Statement? The "json-to-xml" Policy Statement allows you t...
How to register and get an application ID from Azure AD? The first step to use Azure AD is to regist...
How to use the "set-body" Policy Statement for an Azure API service operation? The "set-body" Policy...
What Is session_register() in PHP? session_register() is old function that registers global variable...