diff options
author | Ico Doornekamp <ico@pruts.nl> | 2020-02-17 09:00:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-17 09:00:25 +0100 |
commit | 73553621a11f043bad9cc18cfde525709c49ad7e (patch) | |
tree | a4d0809769c92a47b70829dab3b8a91a8ec0822f | |
parent | 006fe4cfc4b07b7a2eac4cdfeacf7501667a3200 (diff) | |
download | Nim-73553621a11f043bad9cc18cfde525709c49ad7e.tar.gz |
Improved assertion error messages on usage of JsonNode iterators on wrong kinds (#13389)
-rw-r--r-- | lib/pure/json.nim | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim index cb02eb83c..82923ced0 100644 --- a/lib/pure/json.nim +++ b/lib/pure/json.nim @@ -739,33 +739,33 @@ proc `$`*(node: JsonNode): string = iterator items*(node: JsonNode): JsonNode = ## Iterator for the items of `node`. `node` has to be a JArray. - assert node.kind == JArray + assert node.kind == JArray, ": items() can not iterate a JsonNode of kind " & $node.kind for i in items(node.elems): yield i iterator mitems*(node: var JsonNode): var JsonNode = ## Iterator for the items of `node`. `node` has to be a JArray. Items can be ## modified. - assert node.kind == JArray + assert node.kind == JArray, ": mitems() can not iterate a JsonNode of kind " & $node.kind for i in mitems(node.elems): yield i iterator pairs*(node: JsonNode): tuple[key: string, val: JsonNode] = ## Iterator for the child elements of `node`. `node` has to be a JObject. - assert node.kind == JObject + assert node.kind == JObject, ": pairs() can not iterate a JsonNode of kind " & $node.kind for key, val in pairs(node.fields): yield (key, val) iterator keys*(node: JsonNode): string = ## Iterator for the keys in `node`. `node` has to be a JObject. - assert node.kind == JObject + assert node.kind == JObject, ": keys() can not iterate a JsonNode of kind " & $node.kind for key in node.fields.keys: yield key iterator mpairs*(node: var JsonNode): tuple[key: string, val: var JsonNode] = ## Iterator for the child elements of `node`. `node` has to be a JObject. ## Values can be modified - assert node.kind == JObject + assert node.kind == JObject, ": mpairs() can not iterate a JsonNode of kind " & $node.kind for key, val in mpairs(node.fields): yield (key, val) |