import json,strfmt
let jz:JsonNode = parseJson("""{"lat":37.7898,"status":"success","countryCode":"US","city":"San Francisco","country":"United States"}""")
echo jz
echo jz.len
echo jz.getFields()
for x in jz.getFields():
echo "{:<15} : {}".fmt($x.key,$x.val)
This fails with
qq13.nim(8, 8) template/generic instantiation from here
lib/system.nim(2301, 19) Error: undeclared field: 'data'
on latest dev:
Nim Compiler Version 0.13.1 (2016-02-27) [Linux: amd64]
Copyright (c) 2006-2016 by Andreas Rumpf
git hash: 6d2fd0c9f17016ee9ae5f8c337445ff958cba2f0
active boot switches: -d:release
What did I do wrong ?
Thank you for the tip.
Yes it must have to do with this pull.
If I use mpairs instead of getFields:
import json,strfmt
var jz:JsonNode = parseJson("""{"lat":37.7898,"status":"success","countryCode":"US","city":"San Francisco","country":"United States"}""")
echo jz
echo jz.len
echo()
for x in mpairs(jz): echo x
echo()
for x in jz.mpairs(): echo "{:<15} : {}".fmt($x.key,$x.val)
then it compiles again.
That happens because getFields now returns a Table and $ from tables is not imported, works like this:
import json, strfmt, tables
let jz:JsonNode = parseJson("""{"lat":37.7898,"status":"success","countryCode":"US","city":"San Francisco","country":"United States"}""")
echo jz
echo jz.len
echo jz.getFields()
for key, val in jz.getFields():
echo "{:<15} : {}".fmt($key,$val)
We should probably look into re-exporting useful procs like that.