Python json.dump() vs json.dumps(): what is the difference?

Python objects can be encoded into JSON format using the two methods provided by the json module. The json.dump() method (without the "s") converts a Python object into a JSON string and writes it to a file. The json.dumps() method encodes any Python object into a string in JSON format. By passing the indent and sort_keys parameters to the json.dumps() and json.dump() methods, you can pretty print the JSON result; otherwise, compact JSON will be generated.
Loading...