The method for converting a JSON string to a Map object.
The page transmits a json string to the background action, and the json string needs to be converted into a Map object.
Public Map <String, String> toMap (Object object) {Map <String, String> data = new HashMap <String, String> (); // convert the json string to jsonObject JSONObject jsonObject = JSONObject. fromObject (object); Iterator ite = jsonObject. keys (); // traverses jsonObject data and adds it to the Map object while (ite. hasNext () {String key = ite. next (). toString (); String value = jsonObject. get (key ). toString (); data. put (key, value);} // or directly assign the jsonObject value to Map/data = jsonObject; return data ;}
The above method to convert the JSON string into a Map object is all the content shared by the editor. I hope to give you a reference and support for the customer's house.