Hi All, I'm writing a small app, and using the JSON module I have a section of code like this:
var json_response = parseJson(response.body)
echo $json_response["settings"]{"pollingRate"}[].kind
Which works. But, this doesn't:
var json_response = parseJson(response.body)
echo $json_response["settings"]{"pollingRate"}.kind
main.nim(37, 32) Hint: simpleGetOrDefault(json_response["settings"], "pollingRate") --> 'getOrDefault(json_response["settings"], "pollingRate")' [Pattern]
main.nim(37, 32) Error: type mismatch: got (JsonNode) but expected 'JsonNodeObj = object'
When I read the manual, I see:
# no need to write n[].data; in fact n[].data is highly discouraged!
Is this a bug?
this works
import json
let jsonraw = """{
"settings": {
"pollingRate": 5
}
}"""
let jobj = parseJson jsonraw
echo jobj["settings"]["pollingRate"].kind
echo jobj["settings"]{"pollingRate"}
Maybe the problem is in {} proc, using usual [] it works fine