import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import net.sf.json.util.JSONTokener;
public class T {
public static void main(String[] args) {
// String jsonStr ="{\"data\":{\"key\":\"vlaue\"}}";
String jsonStr = "{\"data\":[{\"key\":\"vlaue\"},{\"key1\":\"vlaue1\"},{\"key2\":\"vlaue2\"}]}";
JSONObject jsonObject = JSONObject.fromObject(jsonStr);
Object dataJson = new JSONTokener(jsonObject.getString("data")).nextValue();
if (dataJson instanceof JSONArray) {
System.out.println("+++++++++++++++++arry");
JSONArray dataArray = (JSONArray) dataJson;
for (int i = 0; i < dataArray.size(); i++) {
JSONObject data = dataArray.getJSONObject(i);
System.out.println(data);
}
} else if (dataJson instanceof JSONObject) {
System.out.println("+++++++++++++++++object");
JSONObject dataObject = (JSONObject) dataJson;
System.out.println(dataObject);
}
}
}