Should json restrict string indentation to JSON whitespace?
Discussions on Python.org
Should json restrict string indentation to JSON whitespace?
The json module accepts arbitrary strings for indent. Depending on the string and input data, this can produce invalid JSON or valid JSON with different values. For example: import json data = [1, 2] for indent in ["4", "1", "-", "1e", "1."]: text = json.dumps(data, indent=indent) print(repr(indent), json.loads(text)) '4' [41, 42] '1' [11, 12] '-' [-1, -2] '1e' [10.0, 100.0] '1.' [1.1, 1.2] For a typical object such as {"name": "example", "values": [1, 2]}, those same strings produ...
0 comments
No comments yet.