From 4299ae1c720179e5e94ab0fccb71206f830f17fc Mon Sep 17 00:00:00 2001 From: hlaaftana Date: Wed, 21 Aug 2019 11:34:42 +0300 Subject: [PATCH] Fix #11988 --- lib/pure/json.nim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 1ef08f547e1a..f16d46838cc7 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -158,6 +158,8 @@ when defined(nimJsonGet): else: {.pragma: deprecatedGet.} +const nativeJs = defined(js) and not nimvm + type JsonNodeKind* = enum ## possible JSON node types JNull, @@ -840,7 +842,7 @@ proc parseJson(p: var JsonParser): JsonNode = of tkError, tkCurlyRi, tkBracketRi, tkColon, tkComma, tkEof: raiseParseErr(p, "{") -when not defined(js): +when not nativeJs: proc parseJson*(s: Stream, filename: string = ""): JsonNode = ## Parses from a stream `s` into a `JsonNode`. `filename` is only needed ## for nice error messages. @@ -1769,3 +1771,8 @@ when isMainModule: ) doAssert(obj == to(%obj, type(obj))) + + # bug #11988 + when defined(js): + const jsConstantNode = parseJson("12") + doAssert(jsConstantNode.num == 12)