Tools, FAQ, Tutorials:
What Is json.JSONEncoder Class
What Is json.JSONEncoder Class?
✍: FYIcenter.com
json.JSONEncoder class is the underlying class that supports json.dumps() functions.
The following Python example shows you how to use json.JSONEncoder class to perform the same JSON encoding job as json.dumps function:
>>> import json >>> l = ['foo', {'bar': ('baz', None, 1.0, {"c": 0, "b": 0, "a": 0})}] >>> # Encoding with json.dumps() function >>> j = json.dumps(l, indent=None, separators=(',', ':'), sort_keys=True) >>> print(j) ["foo",{"bar":["baz",null,1.0,{"a":0,"b":0,"c":0}]}] >>> # Encoding with json.JSONEncoder class >>> encoder = json.JSONEncoder(indent=None, separators=(',', ':'), sort_keys=True) >>> j = encoder.encode(l) >>> print(j) ["foo",{"bar":["baz",null,1.0,{"a":0,"b":0,"c":0}]}]
⇒ Extending json.JSONEncoder Class
2018-10-08, 2054🔥, 0💬
Popular Posts:
Where to get the detailed description of the JSON.stringify() Function in JavaScript? Here is the de...
How To Read the Entire File into a Single String in PHP? If you have a file, and you want to read th...
Where to find tutorials on Visual Studio? I want to know How to learn Visual Studio. Here is a large...
Can Multiple Paragraphs Be Included in a List Item? Yes. You can include multiple paragraphs in a si...
How to use "link" command tool to link objet files? If you have object files previously compiled by ...