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

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -