I\'m trying to convert the data from a simple object graph into a dictionary. I don\'t need type information or methods and I don\'t need to be able to convert it back to an
One line of code to convert an object to JSON recursively.
import json def get_json(obj): return json.loads( json.dumps(obj, default=lambda o: getattr(o, '__dict__', str(o))) ) obj = SomeClass() print("Json = ", get_json(obj))