json - Check if Gson JsonArray is empty -
i using httpurlconnection retrieve json string. looks this:
{ "status":"ok", "testsuites":[ { // possibly 1 object in here } ] } i want know if array empty. there @ 1 object in array. tried following:
jsonparser parser = new jsonparser(); jsonobject obj = parser.parse(json).getasjsonobject(); jsonarray testsuites = obj.getasjsonarray("testsuites"); and checked if testsuites null, doesn't work, because it's not null. empty!
i figured out. can use size() method determine number of elements in array.
if (testsuites.size() == 0)
Comments
Post a Comment