The json file must be familiar to everyone. Its flexibility is good. The following describes how js reads and writes json files. This section describes how js reads and writes json files, concise code
Function funSave () {var id = $ ('# testText1') [0]. value; var name = $ ('# testText2') [0]. value; var str = '{mydata: [' + '{id:' + id + ', name:' + name + '}' + ']}'; str = "{MyData: [{id: '" + id + "', name: '" + name + "'}]}"; // var json = eval ('+ str +'); var fso, tf; try {fso = new ActiveXObject ("Scripting. fileSystemObject "); tf = fso. createTextFile ("F: \ BaiduYun \ MyHtml \ DB_USER.json", true); tf. writeLine (str);} catch (err) {} finally {tf. close () ;}} function funSearch () {var fso, ts, s; var ForReading = 1; try {fso = new ActiveXObject ("Scripting. fileSystemObject "); ts = fso. openTextFile ("F :\\ BaiduYun \ MyHtml \ DB_USER.json", ForReading); s = ts. readLine (); var json = eval ('+ s +'); alert (json. myData [0]. id);} catch (err) {} finally {ts. close ();}}