2 ms·
in python you can turn nested dictionaries and other data structures into json, but only if the data structures doesn't include circular references. I use that
by MichaelMoser123 3y ago
in python you can turn nested dictionaries and other data structures into json, but only if the data structures doesn't include circular references. I use that a lot.
something like
>>> d = { "a":1, "b":[1,2,3] }
>>> import json
>>> print( json.dumps(d, indent=2) )
{
"a": 1,
"b": [
1,
2,
3,
]
}
- eesmith 3y agoTry pprint: >>> d = { "a":1, "b":[1,2,3] } >>> d["d"] = d >>> import pprint >>> pprint.pprint(d) {'a': 1, 'b': [1, 2, 3], 'd': <Recursion on dict with id=4516761856>}
- MichaelMoser123 3y agothanks, great!