I am working on project in which I am sending request ot server for getting JSON array string. I am using following java code to create one JSON array list string.
JSONArray itemList = new JSONArray();
for(int i =0; i<4; i++) {
String exe = "m";
final JSONObject jsonObj = new JSONObject();
jsonObj.put("filePath", 30);
jsonObj.put("duration", 12222);
jsonObj.put("bitRate", 1111);
jsonObj.put("widht", 12);
jsonObj.put("format", 123);
jsonObj.put("height", 12);
jsonObj.put("exe", exe);
JSONObject jObject = new JSONObject();
try {
itemList.put(jsonObj);
// jObject.put("itemList", itemList);
} catch (Exception e) {
System.out.println("ERROR");
}
}
return itemList.toString();
On client side, in AJAX response, I am getting following String by using above method:
[{"duration":12222‚"height":12‚"widht":12‚"filePath":30‚"format":123‚"bitRate":1111‚"exe":"m"}‚{"duration":12222‚"height":12‚"widht":12‚"filePath":30‚"format":123‚"bitRate":1111‚"exe":"m"}‚{"duration":12222‚"height":12‚"widht":12‚"filePath":30‚"format":123‚"bitRate":1111‚"exe":"m"}‚{"duration":12222‚"height":12‚"widht":12‚"filePath":30‚"format":123‚"bitRate":1111‚"exe":"m"}]
When I am using JQuery to parse it as follows:
$jQ.each($jQ.parseJSON(responseJSON), function(idx, obj) {
alert(obj.filePath);
});
I am getting JS error as JSON.parse: expected property name or '}'
I am not getting why this error is occuring.