> For the complete documentation index, see [llms.txt](https://js201.gitbook.io/js-101/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://js201.gitbook.io/js-101/json.md).

# JSON

**J**ava**S**cript **O**bject **N**otation (JSON) is a text-based format for storing and transporting data.  The Javascript Objects can be easily converted into JSON and vice versa.  For example.

```javascript
//  a JavaScript object
let myObj = { name:"Ryan", age:30, city:"Austin" };

// converted into JSON:
let myJSON = JSON.stringify(myObj);
console.log(myJSON);
// Result: '{"name":"Ryan","age":30,"city":"Austin"}'

//converted back to JavaScript object
let originalJSON = JSON.parse(myJSON);
console.log(originalJSON);

// Result: {name: 'Ryan', age: 30, city: 'Austin'}
```

`stringify` and  `parse` are the two methods supported by JSON.

<table><thead><tr><th width="216.5">Method</th><th>Description</th></tr></thead><tbody><tr><td><code>parse()</code></td><td>Returns  JavaScript object from the parsed JSON string</td></tr><tr><td><code>stringify()</code></td><td>Returns JSON string from JavaScript Object</td></tr></tbody></table>

&#x20;The following data types are supported by JSON.

* string
* number
* array
* boolean
* object with valid JSON values
* `null`

It can not be `function`,  `date` or `undefined`.
