diff options
author | Timothee Cour <timothee.cour2@gmail.com> | 2021-03-16 13:44:54 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-16 21:44:54 +0100 |
commit | 895a40d1ac305171b8581bed9a951901f5b73328 (patch) | |
tree | 50370cb9fa00e3f13b7b7c19215b0d5f08c55ba5 /lib/std | |
parent | cfe2f126e59eed870e2978ebd263be9ca1be01a3 (diff) | |
download | Nim-895a40d1ac305171b8581bed9a951901f5b73328.tar.gz |
fix #17383: json.%,to and jsonutils.formJson,toJson now works with uint|uint64 (#17389) [backport:1.2]
* fix #17383: json.%,to and jsonutils.formJson,toJson now works with uint|uint64 * fixup * fix for js
Diffstat (limited to 'lib/std')
-rw-r--r-- | lib/std/jsonutils.nim | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/std/jsonutils.nim b/lib/std/jsonutils.nim index bbe6a7cd4..fa61d79db 100644 --- a/lib/std/jsonutils.nim +++ b/lib/std/jsonutils.nim @@ -187,7 +187,8 @@ proc fromJson*[T](a: var T, b: JsonNode, opt = Joptions()) = of JInt: a = T(b.getBiggestInt()) of JString: a = parseEnum[T](b.getStr()) else: checkJson false, $($T, " ", b) - elif T is Ordinal: a = T(to(b, int)) + elif T is uint|uint64: a = T(to(b, uint64)) + elif T is Ordinal: a = cast[T](to(b, int)) elif T is pointer: a = cast[pointer](to(b, int)) elif T is distinct: when nimvm: @@ -270,6 +271,7 @@ proc toJson*[T](a: T): JsonNode = # in simpler code for `toJson` and `fromJson`. elif T is distinct: result = toJson(a.distinctBase) elif T is bool: result = %(a) + elif T is SomeInteger: result = %a elif T is Ordinal: result = %(a.ord) else: result = %a |