[
{
"name": "Test",
"type": "Private",
"item":[{"itmeNo":"PT-15003C","quantity":"3"},
{"itmeNo":"PT-15003C","quantity":"3"}],
"successMsg":"Item(s) added to the job list."
}
]
Hi, I am doing data parameterization using json.Above is my json data, i want to enter this data in one form wherein i need to enter itemNo and quantity together. How can that be done using data parameterization using json. When there is one key-one value pair then my code is working but in this case can anyone please help me getting solution ? I have written following code for single key pair value.
public static Object[][] getData(String path) {
JSONParser parser = new JSONParser();
JSONArray jArray = null;
Object[][] testData = null;
try {
jArray = (JSONArray) parser.parse(new FileReader(System.getProperty("user.dir") + path));
testData = new Object[jArray.size()][1];
Hashtable<String, String> table = new Hashtable<String, String>();
int i = 0;
for (Object obj : jArray) {
table = new Hashtable<String, String>();
JSONObject objJson = (JSONObject) obj;
Set<?> keys = objJson.keySet();
Iterator a = keys.iterator();
while (a.hasNext()) {
String key = (String) a.next();
String value = (String) objJson.get(key);
// System.out.print("key : "+key);
// System.out.println(" value :"+value);
table.put(key, value);
}
testData[i][0] = table;
i++;
}
return testData;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParseException e) {
e.printStackTrace();
}
return null;
}