diff options
author | Yardanico <tiberiumk12@gmail.com> | 2023-04-21 07:11:30 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-21 06:11:30 +0200 |
commit | 418e54452b28d2854fb1106be06e231dac842cf1 (patch) | |
tree | 195d905ea8e3775bb539b1a250441bd054bd6506 /lib | |
parent | f9477396a6f21beaa8ffd3de19129b11fe7169f1 (diff) | |
download | Nim-418e54452b28d2854fb1106be06e231dac842cf1.tar.gz |
Fix json.to for float fields that are not present (#21695)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/json.nim | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 45b22cea5..7ccd3c43f 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -1123,6 +1123,7 @@ proc initFromJson[T: SomeInteger](dst: var T; jsonNode: JsonNode, jsonPath: var dst = cast[T](jsonNode.num) proc initFromJson[T: SomeFloat](dst: var T; jsonNode: JsonNode; jsonPath: var string) = + verifyJsonKind(jsonNode, {JInt, JFloat, JString}, jsonPath) if jsonNode.kind == JString: case jsonNode.str of "nan": @@ -1138,7 +1139,6 @@ proc initFromJson[T: SomeFloat](dst: var T; jsonNode: JsonNode; jsonPath: var st dst = T(b) else: raise newException(JsonKindError, "expected 'nan|inf|-inf', got " & jsonNode.str) else: - verifyJsonKind(jsonNode, {JInt, JFloat}, jsonPath) if jsonNode.kind == JFloat: dst = T(jsonNode.fnum) else: |