JSONPATH - MULTIPLE RECORD SYNTAX IN GROOVYSCRIPT?
I always struggle with JSONPATH relative to XPATH and this is another instance.
I have an assertion in my groovy script with the following syntax for a single record in the resultset - just to clarify - the total attribute within the data node has a value of 'Rich' (JSONPATH generated by readyAPI! would generate $[data][Name])
assert object.data.Name == 'Rich'
BUT - how do I represent multiplicity for multiple records in my resultset?
i.e. if I had 2 records in my result set - so there are 2 'Name' attributes in the data node - the JSONPATH to the individual Name attributes is as follows:
The JSONPATH notation in my groovy differs - does anyone know how to create a specific assertion on each of the above 'Name' attributes?
assert object.data.0.Name == 'Rich'
assert object.data..Name == 'Rich'
As always? I appreciate all/any guidance/help/education anyone's willing to impart! 🙂
Solved! Go to Solution.
So you're saying rather than have individual assertions that definitely describe their location in the response - just have one assertion with the expected results being an array of values?
hahahaha! that'll do!