Source: http://javascript.ruanyifeng.com/stdlib/date.html
//Parse JSON can also pass in a method, basically and stringify almost, but in reverse order, pay attention to the return of key = "", basically return value is good//make a Test yourself better understandfunction f (key, value) {//Console.log (key); //Console.log (value); if(Key = = ="") { returnvalue; } return{age: A }; } varO1 ={name:"keatkeat", array: ["a","b"] } varn \Json.parse (Json.stringify (O1), f); Console.log (o); //The 2nd parameter array, you can filter out the attributes we want to specify for obj//if the 2nd argument is a function, it will be the object and array of the execution set, and the property will be ignored if the undefined is returned.//This key value loop includes the object (key= "", Value=object), an array (key= "", Value=array), each of the attributes within the object (Key=attr,value=value), each value in the array (key= 0, Value=value)//the value of return will continue to be returned to the ladder, for example, if you turn a string into a return object, it will also handle the object (so be aware of circular references)//If you are dealing with an object and it has the ToJSON method, it will be called to get return value (such as JS date with this method)//making a Test yourself is easy to understand. //the 3rd parameter can be a beautiful JSONjson.stringify (obj, function (key, value) {Console.log (key); Console.log (value); //custom processing, you have to worry about this. if(Value.tojson) {returnValue.tojson (); } returnvalue; }, " "); Json.stringify (obj, ["onlythisattrwant"]," ");
JSON stringify and parse