How to check the type of a value from a JSONObject?

后端 未结 6 1377
耶瑟儿~
耶瑟儿~ 2020-11-28 10:05

I\'m trying to get the type of the value stored in a JSONObject.

String jString = {\"a\": 1, \"b\": \"str\"};
JSONObject jObj = new JSONObject(         


        
6条回答
  •  臣服心动
    2020-11-28 10:44

    The best solution is to use JSONObject.get() and check for the type using instanceof operator.

提交回复
热议问题