in JavaScript Json nodes are also maps... hashtables (more or less).
Is it the same with Nim, i.e. is the lookup for keys in a Json node linear or O(n) ?
let jsonNode = parseJson("""{"key": 3.14}""")
doAssert jsonNode.kind == JObject
doAssert jsonNode["key"].kind == JFloat
echo jsonNode["key"]
Take a look at the implementation of the JsonNode type here:
https://github.com/nim-lang/Nim/blob/devel/lib/pure/json.nim#L178-L194
As you can see first of all, a JsonNode is a variant object. The JObject kind, which is the one you implicitly have for key based lookups is just a normal OrderedTable of the stb lib. Since that type is indeed just a hash map, the answer is yes. Key lookup in JSON is indeed usually O(1).