提供一种json 转form数据的方法,还未完成
public class TestUtil {
private List list = new ArrayList<>();
public List getList(String data, String key, int type) {
try {
JSONObject jsonObject = new JSONObject(data);
Iterator iter = jsonObject.keys();
while (iter.hasNext()) {
Map.Entry entry = (Map.Entry) iter.next();
String key1 = entry.getKey().toString();
Object value1 = entry.getValue();
if (value1 instanceof JSONArray) {
for (int i = 0; i < ((JSONArray) value1).length() ; i++) {
Map.Entry entry2 = (Map.Entry) iter.next();
String key2 = entry.getKey().toString();
Object value2 = entry.getValue();
if (value2 instanceof JSONArray) {
if (type == 1) {
list.addAll(getList(value2.toString(), "["+ key1+ "][" + key2 + "]",1 ));
} else {
list.addAll(getList(value2.toString(), key1 + "[" + key2 + "]",1 ));
}
} else if (value2 instanceof JSONObject) {
if (type ==1 ) {
list.addAll(getList(value2.toString(), "["+ key1+ "][" + key2 + "]",1 ));
} else {
list.addAll(getList(value2.toString(), key1 + "[" + key2 + "]",1 ));
}
} else {
if (type == 1) {
} else {
}
}
}
} else if (value1 instanceof JSONObject) {
} else {
}
System.out.println(entry.getKey().toString());
System.out.println(entry.getValue().toString());
}
} catch (JSONException e) {
e.printStackTrace();
}
return null;
}
} 


