Browser-Native JSON Parsing and Serialization
The window.JSON object provides native JSON support in modern browsers, including Internet Explorer 8 , Firefox 3.1 , Safari 4 , and Chrome 3 . This object exposes two methods:
JSON.parse(str)
Parses the JSON string str and returns an object representing the decoded data.
JSON.stringify(obj)
Returns a JSON representation of the JavaScript object obj.
Examples
// Parse JSON string
const data = JSON.parse('{"name": "John", "age": 30}');
// Serialize object to JSON string
const json = JSON.stringify({ name: "Jane", age: 35 });
Additional Information
For more detailed documentation, refer to the MDN article:
[https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON)
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3