String jsonString = "[{reportlet: 'json_export.cpt',param1: 'value1',param2: 'value2'}]";
ArrayList<HashMap<String,Object>> results = new ArrayList<>();
try {
JSONArray reportlets = new JSONArray(jsonString);
for (int i = 0; i < reportlets.length(); ++i) {
HashMap<String,Object> paraMap = new HashMap();
JSONObject jsonObject = reportlets.getJSONObject(i);
Iterator keys = jsonObject.keys();
while (keys.hasNext()) {
String key = (String) keys.next();
Object value = jsonObject.get(key);
value = value instanceof String ? CodeUtils.decodeText(String.valueOf(value)) : value;
paraMap.put(key, value);
}
results.add(paraMap);
}
}
catch(Exception ex){
ex.printStackTrace();
}
|