json

< apis
Jump to: navigation, search

JSON

This article is Almost Ready.



Summary

JSON is a native API for parsing and serialising information to the JSON format.

JSON contains two methods: parse for parsing JSON strings, and stringify for converting a JavaScript object into JSON.


Properties

No properties.

Methods

API Name Summary
parse Parse a JSON string to a JavaScript object.
stringify Export a JavaScript object to a JSON string.


Events

No events.



Compatibility

There is no data available for topic "webapi", feature "json". If you think that there should be data available, consider opening an issue.

Examples

Convert a JavaScript object to a string.

JavaScript

var js_object = {
    type: "This is a Javascript Object."
};

var json_string = JSON.stringify(js_object);

Parse a JSON string to a JavaScript object.

JavaScript

var json_string = '{type:"This is a JSON Object."}';
var js_object = JSON.parse(json_string);
alert(js_object.type);

Notes

Browsers without JSON support can be polyfilled using third party JavaScript libraries.