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.