Open enthus1ast opened 2 years ago
Looks like the problem is from the hcode
num being too large so its parsed as a raw num (which acts like a string)
json.nim has the logic for handling raw nums but doesn't pick up that the number could be too large since Hash
is defined as just int and so doesn't believe it could to too large
solution might be making Hash
a distinct type so it can be overloaded properly in json.
But there is also a workaround for the example you gave where you properly convert it to JSON so that it isn't sending hashes (not fully tested but something like this should work)
proc toJsonHook*[T](table: Table[int, T]): JsonNode =
result = newJObject()
for k, v in table: result[$k] = %v
proc fromJsonHook*[V](t: var Table[int, V], jsonNode: JsonNode) =
clear(t)
for k, v in jsonNode:
t[k.parseInt()] = jsonTo(v, V)
What happened?
Unserializing a table on the js target fails. The c backend works. Just run the code once on the c target, to generate the data. Then run it on the js target to see the error.
Nim Version
Current Standard Output Logs
No response
Expected Standard Output Logs
No response
Possible Solution
No response
Additional Information
No response