Thank you Klaus.
I have added the following handy (to me, anyway) function to it:
Code:
Function CountAtPath Handle hoJson String sPath Returns Integer
Integer iCount
Get JsonAtPath hoJson sPath to hoJson
If not hoJson ;
Function_Return 0
If (JsonType(hoJson) = jsonTypeArray) ;
Get MemberCount of hoJson to iCount
Send Destroy of hoJson
Function_Return iCount
End_Function
Which lets you, obviously, find the number of array members at a given path: Move (CountAtPath(oJPath, hoJson, "foo.bar.baz")) to iCount.
One word of warning, while getting ValueAtPath to a boolean works OK, using it in a boolean test requires a little extra:
Code:
If (ValueAtPath(oJPath, hoJson, "foo.bar.baz[2]")) Showln "Value True" // Always says: "Value True"
Else Showln "Value False"
// So you need to write:
If (Integer(ValueAtPath(oJPath, hoJson, "foo.bar.baz[2]"))) Showln "Value True"
Else Showln "Value False"
The reason of course is that it is returning the string "0" or "1" for JSON false or true, respectively. And any non-empty string evaluates as true.
Mike