added == for PJsonNode

This commit is contained in:
Billingsly Wetherfordshire
2014-05-03 16:49:41 -05:00
parent 24babdedf1
commit 4099abc867

View File

@@ -619,6 +619,25 @@ proc `%`*(elements: openArray[PJsonNode]): PJsonNode =
newSeq(result.elems, elements.len)
for i, p in pairs(elements): result.elems[i] = p
proc `==`* (a,b: PJsonNode): bool =
if a.kind != b.kind: false
else:
case a.kind
of JString:
a.str == b.str
of JInt:
a.num == b.num
of JFloat:
a.fnum == b.fnum
of JBool:
a.bval == b.bval
of JNull:
true
of JArray:
a.elems == b.elems
of JObject:
a.fields == b.fields
proc len*(n: PJsonNode): int =
## If `n` is a `JArray`, it returns the number of elements.
## If `n` is a `JObject`, it returns the number of pairs.