def count = * print response.teams[0].teamMembers.length
throws below error
com.jayway.jsonpath.PathNotFoundException: Expected to find an object with property ['length'] in path $['teams'][0]['teamMembers'] but found 'net.minidev.json.JSONArray'.
This is not a json object according to the JsonProvider: 'com.jayway.jsonpath.spi.json.JsonSmartJsonProvider'.
print response.teams[0].teamMembers.length
andassert response.teams[0].teamMembers.length == 9
are working just fine.
Any help here is much appreciated.
Yes, Karate assumes the right-hand-side as Json-Path (which is fine for 90% of the cases). Use parentheses to force JavaScript evaluation when needed.
Try this:
For a detailed explanation, please refer to this section in the documentation: Karate Expressions