Reputation: 321
I am using APIs to fetch details from BMC Remedy, and the response is a json which is containing an jsonarray which is empty, so just to avoid such cases I am checking whether the jsonarray is empty or not.
This is the response received when the call is done via postman and I want ot check the jsonarray entries
And the same call I am able to replicate in the groovy code also, only thing is when checking whether the jsonarray is empty I receive an exception.
This is the code and output snippet when printing the value of JSONarray
However as soon as I try and check if the JSONarray is Empty it gives me error.
Failing code snippet
I know, I can alternatively use the length() method and check, However I need to know why this code is failing, Please help I am quite new to groovy.
I have also imported java.util.List and tried but no luck
Upvotes: 0
Views: 532
Reputation: 187529
A MissingMethodException
is thrown because JSONArray
does not have a method named isEmpty()
.
I think you're confusing org.json.JSONArray
and web.json.JSONArray
. The latter does have a method isEmpty()
, but you're using the former.
Upvotes: 1