JSON serialization of objects containing tuples

2021-09-05 Thread Stefan_Salewski
> Restriction: For objects, their type is not serialized. This means > essentially that it does not work if the object has some other runtime type > than its compiletime type. Yes, that is stated very clear for the JSON module, and I think for the Marshal module too. It is sad, but I guess ther

JSON serialization of objects containing tuples

2021-09-05 Thread planetis
First of since you rely in oop heavily, I should warn you about the limitation marshal and friends have: > Restriction: For objects, their type is not serialized. This means > essentially that it does not work if the object has some other runtime type > than its compiletime type. Also cyclic o

Choosenim installs older stable?

2021-09-05 Thread upholstered
Thanks @dom96, I will file an issue for this if it can be helpful.

JSON serialization of objects containing tuples

2021-09-05 Thread Stefan_Salewski
And for my other question with back references -- for JsonUtils serialization already gives a crash at runtime, so it makes no sense to ask if deserialization would work: import json, marshal, std/jsonutils type V2 = tuple[x, y: float] type Element = re

JSON serialization of objects containing tuples

2021-09-05 Thread Stefan_Salewski
Thanks for that example. Indeed it works -- as I wrote in my last post, my issue was that I took the import statement verbatim from the first JsonUtils API doc example: import std/[strtabs,json] Run You example gives this output: [139991162843216, {"line

JSON serialization of objects containing tuples

2021-09-05 Thread ynfle
You can also use jsony

JSON serialization of objects containing tuples

2021-09-05 Thread konradmb
Can you post a full example? Because it's working in playground that I posted earlier.

JSON serialization of objects containing tuples

2021-09-05 Thread Stefan_Salewski
Ah, I took the import statement from the example, seem JsonUtils was missing. With import std/[strtabs,json, jsonutils] Run I get {"lines":[],"circs":[],"texts":[],"rects":[],"pads":[],"paths":[],"pins":[],"traces":[],"p":[],"at":[],"hover":false,"select

JSON serialization of objects containing tuples

2021-09-05 Thread Stefan_Salewski
I saw that module already. But with the example from above and let j =g.toJson I get /home/salewski/SDTold/jmom.nim(64, 11) Error: undeclared field: 'toJson' for type jmom.Group [type declared in /home/salewski/SDTold/jmom.nim(48, 3)]| ---|--- There is even one more JSON module:

JSON serialization of objects containing tuples

2021-09-05 Thread konradmb
Use `toJson` from `std/jsonutils`.

JSON serialization of objects containing tuples

2021-09-05 Thread Stefan_Salewski
After replacing the tuple with array it seems to work, at least the serialization. We get an output from pretty(%* g) like saveGroup { "lines": [ { "style": "medium", "p": [ [ 370.0, 190.0 ],

Is there a way to get value as if it's reference and update it's value?

2021-09-05 Thread jackhftang
FYI, for truly functional programming style, you should think of returning a new table value and use **lenses** to help you get/set values in nested structures.