pykson icon indicating copy to clipboard operation
pykson copied to clipboard

Being able to serialize a dictionary containing objects to be serialized.

Open CustomEntity opened this issue 4 years ago • 3 comments

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 !

CustomEntity avatar Jan 11 '21 12:01 CustomEntity

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?

sinarezaei avatar Jan 13 '21 09:01 sinarezaei

I have no idea what it's going to look like in the end, but yes, with a complex object as a key

CustomEntity avatar Jan 13 '21 18:01 CustomEntity

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).

OverShifted avatar Mar 20 '21 16:03 OverShifted