我将数组返回为
$array = array {
'id' => 1,
'name'=>krishna,
}
echo json_encode($array);
exit;
来自 ajax 调用
如何将此 json 值转换为 java 脚本数组?
这是我的实际数据
var data = [{
"candidate_notes_id":"1",
"candidate_id":"38",
"subject":"test",
"description":"testestsete\netestes\n\n\nsteetet",
"private":"0",
"created_date":"2012-09-14 11:55:13",
"updated_date":"2012-09-14 11:55:13",
"updated_by":"admin"
}]
var newArray = jQuery.parseJSON(data);
alert(newArray);
return false;
结果 :
var newArray = JSON.stringify(data);
var date_split = newArray.substr(1,newArray.length-2);
var newData = date_split.replace('\n','<br>');
var newArray = $.parseJSON(newData);
alert(newArray.candidate_notes_id);
alert(newArray.candidate_id);
alert(newArray.subject);
alert(newArray.description);