Quantcast
Channel: New board topics in SmartBear Community
Viewing all articles
Browse latest Browse all 20755

how to determine whether json is jsonArray or jsonObject

$
0
0

Hi All,

 

I am currently stucked at a point where i need to check whether the given json contains array or not.

 

Can any one help me on this:

 

Suppose below is my json:

 

{

"status":"pass",

"code":200,

"data":{

          "abc":[{

          "a1" : "test1"

          "a2" : "test2"

          "a3" : "test3"

          "a4" : "test4"

          },

          {

          "a1" : "test1"

          "a2" : "test2"

          "a3" : "test3"

          "a4" : "test4"

          }],

          "xyz":{

               "b1":"T1"

               "b2":"T2"

               }

     }

}

 

def jsonSlurperTU = new JsonSlurper().parseText(TUResponse)

def expected = jsonSlurperTU.data.abc

def expected1 = jsonSlurperTU.data.xyz

 

i need to check whether xyz is json array or json object as the above json is dummy my json is of 4000 line.

 

 


Viewing all articles
Browse latest Browse all 20755

Trending Articles