JSON => String:
Jsontostring:function (obj) {var this = this;
Switch (typeof (obj)) {case ' string ': Return ' ' ' + obj.replace ([[]]/g, ' \\$1 ') + ' ';
Case ' array ': return ' [' + Obj.map (this.jsontostring). Join (', ') + '] ';
Case ' object ': if (obj instanceof Array) {var strarr = [];
var len = obj.length;
for (var i=0 i<len; i++) {Strarr.push (this.jsontostring (obj[i));
Return ' [' + strarr.join (', '] + '] ';
}else if (obj==null) {return ' null ';
}else{var string = [];
For (Var, in obj) String.push (this.jsontostring) + ': ' + this.jsontostring (Obj[property]);
Return ' {' + string.join (', ') + '} ';
Case ' number ': return obj;
Case False:return obj; }
},
String => JSON
Stringtojson:function (obj) {return
eval (' + obj + ') ');
The above is a small series for everyone to bring the JSON and string of the implementation of the method (Javascript) of the whole content, hope to help everyone, a lot of support cloud Habitat Community ~