This section describes how to read and write JSON file under JS, the code is very concise
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 ();
}