18 Commits

Author SHA1 Message Date
Eric
cdba47becf
fix: force symbol resolution for types that serde de/serializes (#24)
* fix: force symbol resolution for types that serde de/serializes

Force symbols into scope when mixins are used with generic overloads. When mixins are used with generic overloads, the overloaded symbols in scope of the mixin are evaluated from the perspective of the mixin. This creates issues in downstream modules that may inadvertantly dispatch *only* to the symbols in the scope of the mixin, even when the module with the wrong symbol overloads is not imported. By forcing the compiler to use symbols for types handled by serde, we can be sure that these symbols are available to downstream modules. We can also be sure that these `fromJson` symbols can be overloaded where needed.

* remove enum forced scoping

Forcing a scoping for a particular enum type would only resolve that type and not all enum types.

* Add mixin + generic overloads as known issue to README

* try to fix URL reference to deserializer.nim
2024-05-21 12:39:47 +10:00
Eric
10271bd494
feat: improve deserialization from string (#23)
Improves how types handle deserialization from string, including Option[T], seq[T], and Option[seq[T]]
Empty and null strings are no longer deserialized to 0, instead an error Result is returned
If an error occurs when parsing json, a JsonParseError is returned.
2024-05-16 17:57:42 +10:00
Eric
6d2fc9406a
feat: improve stint parsing (#22)
- change empty string value to none when optional
- handle null, "null", JNull, seq[stint], seq[?string]
2024-05-16 15:09:01 +10:00
Eric
3957da5b52
fix: UInt256 not correctly deserializing from string (#18)
fix: UInt256 not correctly deserialzing from string

UInt256 was being deserialized as an object when being deserialized from a string (not a JString).
2024-05-14 14:45:42 +10:00
Ben Bierens
a4a6b0d949
Fix log topics (#14)
adds serde log topics

moves `logScope` into routine scope due to a bug in chronicles
2024-04-26 18:25:02 +10:00
Eric
e67f7e4b04
deserialize seq[T] and Option[T] from string (#9) 2024-02-14 15:42:42 +11:00
Eric
a2cca7788b
deserialize non-prefixed stuint (#10) 2024-02-14 15:40:32 +11:00
Eric
96ae7e130e
fix: change serializer funcs to procs (#7)
* change serializer funcs to procs

`%` could have side effects if called from chronicles

* clean up
2024-02-13 17:38:18 +11:00
Eric
b04435fb88
Change parseJson to JsonNode.parse (#4)
* Change parseJson to JsonNode.parse

Exporting `parseJson` causes symbol clashes in downstream repos that import std/json, so changing the signature completely avoid this clash.

* Fix usages of parseJson, update README
2024-02-09 11:08:14 +11:00
Eric
1b77afcbf1
Fix deserialization of openArray[byte] (#2) 2024-02-09 10:33:14 +11:00
Eric
6522b219f8
add parent error to parseJson exceptions 2024-02-08 17:01:38 +11:00
Eric
681f32aba6
chore: format using nph 2024-02-08 09:18:55 +11:00
Eric
d877872127
Add prettified option for toJson 2024-02-08 08:09:14 +11:00
Eric
1a506be83a
change common module to parser 2024-02-08 07:12:11 +11:00
Eric
92f7f7e6c5
Move modules into json folder, to make way for other types of serde 2024-02-07 14:44:13 +11:00
Eric
b6cf703ece
rename json module to stdjson 2024-02-07 14:40:00 +11:00
Eric
e15c8b71d7
Renamed serialize and deserialize to avoid clash with pramgas
Working 0.1.0!
2024-02-07 13:41:37 +11:00
Eric
d0a67a8eb0
initial impl, not compiling 2024-02-07 09:40:48 +11:00