pykson
pykson copied to clipboard
Being able to serialize a dictionary containing objects to be serialized.
Hello, would you like to know if it would be possible to add a way to serialize a dictionary please?
Because when I make this code, it works.
st = Story([Action(Chapter("Chapitre 1"), "Discussion", "Contenu"), Action(Chapter("Chapitre 1"), "Discussion", "Contenu")]) print(pykson.Pykson().to_json(st))
But when I want to implement my DAG, I cannot.
graph = { Action(Chapter("Chapitre 1"), "Discussion", "Contenu"): [Action(Chapter("Chapitre 1"), "Discussion", "Contenu")], Action(Chapter("Chapitre 1"), "Discussion", "Contenu"): [Action(Chapter("Chapitre 1"), "Discussion", "Contenu"), Action(Chapter("Chapitre 1"), "Discussion", "Contenu")], Action(Chapter("Chapitre 1"), "Discussion", "Contenu"): [Action(Chapter("Chapitre 1"), "Discussion", "Contenu"), Action(Chapter("Chapitre 1"), "Discussion", "Contenu")], Action(Chapter("Chapitre 1"), "Discussion", "Contenu"): [Action(Chapter("Chapitre 1"), "Discussion", "Contenu")]} print(pykson.Pykson().to_json(graph))
Looking forward to hearing from you, thanks !
Can you please give an example of the json result you want to get after serializing graph? You want json keys to be complex objects?
I have no idea what it's going to look like in the end, but yes, with a complex object as a key
Hi. In the JSON standard; only string keys are allowed. you can't use other things like a JSON object as a key, even though it is possible as a value (obviously).