java - How can the datatype of a JSON property be determined? -


in java, know can check if key present isnull() method. there way check kind of data key holds?

consider following examples.

i want function jsonbody.getdatatype("key") , return string

{     "key" : "value" } 

i want function jsonbody.getdatatype("key") , return jsonobject

{     "key" : {          "parm1" : "value1",         "parm2" : "value2"     } } 

i want function jsonbody.getdatatype("key") , return jsonarray

{     "key" : [         "value1",         "value2",         "value3"     ] } 

i want function jsonbody.getdatatype("key") , return boolean

{     "key" : true } 

does exist?

jsonobject stuff = new jsonobject(whatever); object thing = stuff.get("key"); string classnameofthing = thing.getclass().getname(); systen.out.println("thing " + classnameofthing); if (thing instanceof integer) {     system.out.println("thing integer"); }  

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -