added == for PJsonNode
This commit is contained in:
parent
24babdedf1
commit
4099abc867
1 changed files with 19 additions and 0 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue