In the previous section, we explained JSON. the basic usage of stringify (). In this section, we will focus on serialization. Using these two parameters (Filter Arrays) independently or in combination can provide more comprehensive and in-depth control over JSON serialization, if you are interested, you may be able to learn json. In the previous section, we explained JSON. the basic usage of stringify (). This section focuses on serialization.
In addition to the js object to be serialized, JSON. stringify () can also receive two other parameters, which are used to specify different methods to serialize js objects. The first parameter is a filter that can make an array or a function. The second parameter is an option that indicates whether to retain indentation in the JSON string. These two parameters can be used independently or in combination to control JSON serialization in a more comprehensive and in-depth manner.
1. filter results
If the filter parameter is an array, the result of JSON. stringify () will only contain the attributes listed in the array. For example:
The Code is as follows: