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

后端 未结 6 1378
耶瑟儿~
耶瑟儿~ 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条回答
  •  猫巷女王i
    2020-11-28 11:06

    You can parse all the data as String and then try to convert it to the desired type. At this point you may catch the exception and determine which type is the parsed data.

提交回复
热议问题