Home >Web Front-end >JS Tutorial >js parsing and serializing json data (3) Discussion on json parsing_json
In this section we mainly discuss the parsing of json.
The JSON.parse() method can also receive another parameter, which is a function that will be called on each key-value pair. In order to distinguish the replacement (filter) function (replacer) received by JSON.stringify(), this function is called the restore function (reviver), but in fact the signatures of the two functions are the same - they both receive two parameters, A key and a value, and both need to return a value.
If the restore function returns undefined, it means that the corresponding key is to be removed from the result; if another value is returned, the value is inserted into the result. For example: