@@ -0,0 +1,1461 @@
+package com.foc.util;%0D%0A%0D%0Aimport java.util.ArrayList;%0D%0Aimport java.util.HashMap;%0D%0Aimport java.util.Iterator;%0D%0Aimport java.util.List;%0D%0Aimport java.util.Map;%0D%0A%0D%0Aimport org.json.JSONArray;%0D%0Aimport org.json.JSONException;%0D%0Aimport org.json.JSONObject;%0D%0A%0D%0Apublic class JSONUtil %7B%0D%0A%09%0D%0A%09public static Map%3CString, Object%3E jsonToMap(JSONObject json) throws JSONException %7B%0D%0A%09%09Map%3CString, Object%3E retMap = new HashMap%3CString, Object%3E();%0D%0A%0D%0A%09%09if(json != JSONObject.NULL)%7B%0D%0A%09%09%09retMap = toMap(json);%0D%0A%09%09%7D%0D%0A%09%09return retMap;%0D%0A%09%7D%0D%0A%0D%0A%09public static Map%3CString, Object%3E toMap(JSONObject object) throws JSONException %7B%0D%0A%09%09Map%3CString, Object%3E map = new HashMap%3CString, Object%3E();%0D%0A%0D%0A%09%09Iterator%3CString%3E keysItr = object.keys();%0D%0A%09%09while (keysItr.hasNext())%7B%0D%0A%09%09%09String key = keysItr.next();%0D%0A%09%09%09Object value = object.get(key);%0D%0A%0D%0A%09%09%09if(value instanceof JSONArray)%7B%0D%0A%09%09%09%09value = toList((JSONArray) value);%0D%0A%09%09%09%7D%0D%0A%0D%0A%09%09%09else if(value instanceof JSONObject)%7B%0D%0A%09%09%09%09value = toMap((JSONObject) value);%0D%0A%09%09%09%7D%0D%0A%09%09%09map.put(key, value);%0D%0A%09%09%7D%0D%0A%09%09return map;%0D%0A%09%7D%0D%0A%0D%0A%09public static List%3CObject%3E toList(JSONArray array) throws JSONException %7B%0D%0A%09%09List%3CObject%3E list = new ArrayList%3CObject%3E();%0D%0A%09%09for(int i = 0; i %3C array.length(); i++)%7B%0D%0A%09%09%09Object value = array.get(i);%0D%0A%09%09%09if(value instanceof JSONArray)%7B%0D%0A%09%09%09%09value = toList((JSONArray) value);%0D%0A%09%09%09%7D%0D%0A%0D%0A%09%09%09else if(value instanceof JSONObject)%7B%0D%0A%09%09%09%09value = toMap((JSONObject) value);%0D%0A%09%09%09%7D%0D%0A%09%09%09list.add(value);%0D%0A%09%09%7D%0D%0A%09%09return list;%0D%0A%09%7D%0D%0A%09%0D%0A%09%0D%0A %0D%0A%7D%0D%0A

Add JSONUtil a JSON helper class