Array size using jsonpath expression - Stefan Goessner JsonPath Array size using jsonpath expression - Stefan Goessner JsonPath arrays arrays

Array size using jsonpath expression - Stefan Goessner JsonPath


It seems that support for returning the length() of an array was only added in version 2.1.0 of the jayway json-path library.

Based on some quick tests, the $.orders.length() expression seems to work with both version 2.1.0 and version 2.2.0, so I think you just need to upgrade your dependency version in order to fix the error you are seeing.


List values = jsonpath.getList("orders");System.out.println("Size of object : "+ values.size());