The page passes 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>(); // 将json字符串转换成jsonObject JSONObject jsonObject = JSONObject.fromObject(object); Iterator ite = jsonObject.keys(); // 遍历jsonObject数据,添加到Map对象 while (ite.hasNext()) { String key = ite.next().toString(); String value = jsonObject.get(key).toString(); data.put(key, value); } // 或者直接将 jsonObject赋值给Map // data = jsonObject; return data; }
The above method of converting a JSON string into a Map object is all the content shared by the editor.