{
total: 45,
page: 0,
count: 10,
rows: [
[ 1, 'Folder 1', '2009-01-24' ],
[ 2, 'Folder 2', '2004-02-23' ],
[ 3, 'Folder 3', '2004-02-23' ],
[ 4, 'Folder 4', '2009-01-24' ],
[ 5, 'Folder 5', '2004-02-23' ],
[ 6, 'Folder 6', '2004-02-23' ],
[ 7, 'Folder 7', '2009-01-24' ],
[ 8, 'Folder 8', '2004-02-23' ],
[ 9, 'Folder 9', '2004-02-23' ],
[ 10, 'Folder 10', '2004-02-23' ]
]
}
这是JSON文件,我想修改将Folder 2改为“FolderNewName”,怎么修改呀?谢谢

解决方案 »

  1.   

    给对象一个名字
    比如叫json
    json.row2[2][2] = 'FolderNewName';
      

  2.   

    这段数据是存在一个名为data_0.txt中,
    我用下面的语句访问这个文件
    var url = "/js_test/data_0.txt";
    txthttp = new ActiveXObject("Microsoft.XMLHTTP");    
    txthttp.open("POST",url,true);
    txthttp.onreadystatechange = jsonResponse;
    txthttp.send(null);
    function jsonResponse() {    
       var card = eval('(' + txthttp.responseText + ')');  
       card.rows[0][1]="FolderNewName";..这条语句用于修改
    }现在的问题是:我用card.rows[0][1]="FolderNewName";修改语句后,如何把它存储在这个data_0.txt中。要求:必须用ajax这种方式操纵数据。。
    谢谢大家!!
      

  3.   


    貌似应该是:json.row2[1][1] = 'FolderNewName';数组的下标应该是从0开始的
      

  4.   


    要想把文件存储在服务器上,得用服务器应用程序比如.asp或.jsp用ajax把修改后的所有值 在发回服务器,然后保存