Js parsing and serialization of json data (ii) serialization exploration _ json

Source: Internet
Author: User
Tags tojson
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:





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.