var testStr = '[{"aa":"a1","bb":"b1","cc":"c1","dd":"d1"},{"aa":"a2","bb":"b2","cc":"c2","dd":"d2"},{"aa":"a3","bb":"b3","cc":"c3","dd":"d3"},{"aa":"a4","bb":"b4","cc":"c4","dd":"d4"},{"aa":"a5","bb":"b5","cc":"c5","dd":"d5"}]';
這個testStr是什麼類型?如何給它添加新的內容?
補充:這樣this.objectlist = eval('('+testStr+')');,有什麼用哦?eval後得到的什麼?
這是json格式的字符串
<!DOCTYPE html>
<html>
<body>
<script>
var testStr = '[{"aa":"a1","bb":"b1","cc":"c1","dd":"d1"},{"aa":"a2","bb":"b2","cc":"c2","dd":"d2"},{"aa":"a3","bb":"b3","cc":"c3","dd":"d3"},{"aa":"a4","bb":"b4","cc":"c4","dd":"d4"},{"aa":"a5","bb":"b5","cc":"c5","dd":"d5"}]';
var jsontext = eval('('+testStr+')');
for(var i=0;i<jsontext.length;i++){
document.write(jsontext[i].aa+',');
jsontext[i]['添加內容']='cccc';
document.write(jsontext[i].添加內容+',');
}
</script>
</body>
</html>