Given json such as
{"arr1" : [1,2,3], "arr2" : []}
where it is known that there are arrays named arr1 and arr2, is there a jsonpath expression for the length of the array that will work for both empty and non-empty arrays?
I made several attempts using the JsonPath library for Google code, noting:
JsonPath.read(json, "arr1.length")
but it gives an error saying arrays have no attributes.
I am looking for one string path that resolves the length of an array, and not a subsequent call to an intermediate element, e.g.
JsonPath.read(json, "arr1").length
Any level of expression complexity is acceptable.
In the context, I want to pass a test case with path / value pairs, which works great for values, but I cannot validate the size of the array using this template.
source share