JSON 배열 문자열을 가져 오기 위해 요청 서버를 보내고있는 프로젝트에서 작업 중입니다. 내가 하나의 JSON 배열 목록 문자열을 만들려면 다음 자바 코드를 사용하고 있습니다.JSON 배열 문자열을 구문 분석 할 수 없습니다.
[{"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"}]
나는 다음과 같이 구문 분석 jQuery를 사용하고 때 :
클라이언트 측에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();
, AJAX 응답에서, 나는 방법보다 사용하여 다음과 같은 문자열을 얻고있다
$jQ.each($jQ.parseJSON(responseJSON), function(idx, obj) {
alert(obj.filePath);
});
JS 오류가 발생했습니다 JSON.parse: expected property name or '}'
왜이 오류가 발생하는지 알 수 없습니다. uring.
이 JSON에서 실수가있다, 당신은 그것을 OBJ ... 당신이 자바 스크립트가 필요하지 않은 이유는 점점 – Defoncesko
JSON을 볼 수 당신의 JSON 여기 -> http://jsonlint.com/ 붙여 넣기 구문 분석 할 것입니다 – VostanAzatyan
JSON이 유효하지 않습니다 ... – VostanAzatyan