diff options
author | Araq <rumpf_a@web.de> | 2011-04-01 15:07:16 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2011-04-01 15:07:16 +0200 |
commit | 4741e8f9a1d1148d58e129626952219e14ede255 (patch) | |
tree | db2eca2249ccc3230dc6c0a7359986198cab4048 /lib/pure/json.nim | |
parent | dc669155e39007f1b584eef247dff90523f836bf (diff) | |
download | Nim-4741e8f9a1d1148d58e129626952219e14ede255.tar.gz |
ugh, maybe broke git
Diffstat (limited to 'lib/pure/json.nim')
-rwxr-xr-x | lib/pure/json.nim | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim index 7fbc8bfcf..c90c071b6 100755 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -700,6 +700,18 @@ proc `$`*(node: PJsonNode): String = result = "" toPretty(result, node, 1, False) +iterator items*(node: PJsonNode): PJSonNode = + ## Iterator for the items of `node`. `node` has to be a JArray. + assert node.kind == JArray + for i in items(node.elems): + yield i + +iterator pairs*(node: PJsonNode): tuple[key: string, val: PJsonNode] = + ## Iterator for the child elements of `node`. `node` has to be a JObject. + assert node.kind == JObject + for key, val in items(node.fields): + yield (key, val) + proc eat(p: var TJsonParser, tok: TTokKind) = if p.tok == tok: discard getTok(p) else: raiseParseErr(p, tokToStr[tok]) @@ -711,7 +723,7 @@ proc parseJson(p: var TJsonParser): PJsonNode = result = newJString(p.a) discard getTok(p) of tkInt: - result = newJInt(parseInt(p.a)) + result = newJInt(parseBiggestInt(p.a)) discard getTok(p) of tkFloat: result = newJFloat(parseFloat(p.a)) |