在下面的代码,JSON不能很好形成错误
<head>
<meta charset="UTF-8">
<title>JSON ex</title>
<script type = "text/javascript"
src = "http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js">
</script>
<script type="text/javascript" language = "javascript">
var accountGrid = [];
$(document).ready(function(){
$.getJSON('result.json', function(entry){
accountGrid.push({
name: entry.name,
marketValue: entry.marketValue,
cash: entry.cash,
legend: entry.legend
});
});
});
</script>
</head>
<body>
</body>
result.json
{
'name': 'Account1',
'marketValue': '10990',
'cash': '199926',
'legend': 'orange'
},
{
'name': 'Account2',
'marketValue': '156590',
'cash': '133856',
'legend': 'darkorange'
}
我看到JSON not well formed
错误。 result.json
坐在同一个文件夹中。
由于此错误,accountGrid
变空。
在执行jQuery.getJSON
时出错not well formed
是什么意思?
您可以使用在线/脱机验证程序来验证您的JSON。 – Drumbeg