# How to store data in JSON file in Node-RED

**URL:** https://discourse.nodered.org/t/how-to-store-data-in-json-file-in-node-red/6480
**Category:** General
**Created:** [6 January 2019 23:56 UTC](https://discourse.nodered.org/t/how-to-store-data-in-json-file-in-node-red/6480 "2019-01-06T23:56:57Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)
#### Post date: [7 January 2019 23:14 UTC](https://discourse.nodered.org/t/how-to-store-data-in-json-file-in-node-red/6480/3 "2019-01-07T23:14:56Z")

</div>

@hazymat, I started out using a database for this sort of thing, storing the current state of each device and updating it at every change. Since the introduction of persistent storage, I have gone back to using a JSON file for the static information about my devices and a global variable to store state information. In your case, a JSON file with something like this could store the device description:

```
[{"device":"Light 1",
"zone":"bedroom1",
"name":"Wall Light"
"fitting":"wall",
"colour":"warmwhite"},
{"device":"Light 2", 
"zone":"bedroom1",
"name":"Ceiling Light",
"fitting":"ceiling",
"colour":"RGB"}]

```

You can read the file and pass the payload through a `JSON` node. You get an array of objects that can be saved as a global variable or run through a `split` node to get a message or variable for each device. It's easy to edit the JSON in a text editor to add a new device or modify an old one.

---

_[View the full topic](https://discourse.nodered.org/t/how-to-store-data-in-json-file-in-node-red/6480)._
