The json string to the json object universal converter (implemented in java) is one hundred lines of code, which is very lightweight and compact. For general application scenarios, resource consumption is very low and the speed is fast enough, especially for Android application development.
CommonJSONParser can be used to convert a json String to a set of standard Java objects, such as Map, List, String, and Integer. Usage:
CommonJSONParser commonJSONParser = new CommonJSONParser ();
Map <String, Object> result = commonJSONParser. parse (jsonDataStr );
CommonJSONParser source code ):
Map<String, Object> Map<String, Object> result = ( != JSONObject jsonObject = result = } } Object parseValue(Object inputObject) Object outputObject = ( != (inputObject outputObject = } (inputObject outputObject = } (inputObject String || inputObject Boolean || inputObject outputObject = List<Object> parseJSONArray(JSONArray jsonArray) List<Object> valueList = ( != valueList = ArrayList<Object> ( i = 0; i < jsonArray.length(); i++ Object itemObject = ( != } } Map<String, Object> parseJSONObject(JSONObject jsonObject) Map<String, Object> valueObject = ( != valueObject = HashMap<String, Object> Iterator<String> keyIter = String keyStr = Object itemObject = ( != } } } }