# Storing Complex JSON Payload to Device State Node

**URL:** <https://forums.losant.com/t/storing-complex-json-payload-to-device-state-node/2034>\
**Category:** Help\
**Tags:** workflow\
**Created:** [July 29, 2019, 11:10am UTC](https://forums.losant.com/t/storing-complex-json-payload-to-device-state-node/2034 "2019-07-29T11:10:07Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![anaptfox](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/anaptfox/32/873_2.png) [@anaptfox](https://forums.losant.com/u/anaptfox)\
**Post date:** [July 29, 2019, 2:54pm UTC](https://forums.losant.com/t/storing-complex-json-payload-to-device-state-node/2034/2 "2019-07-29T14:54:22Z")

</div>

Hi @Alexander_Kondrov,

I think this is a great question.

We like to think of all Device State data as being time-series data. Since time-series data is optimized for aggregations, that’s why they are single values (number, boolean, etc.). It’s tough to aggregate a complex JSON object over a specified amount of time.

But you do have options!

1. Because [Device State](https://docs.losant.com/devices/state/) can be a string, we’ve seen cases where other Losant Developers have encoded the JSON and stored that value as the attribute. But, this is not the best because you’ll always need to encode/decoded to use/store that value. Overall, we recommend saving the single values as this would allow you to aggregate and visualize them efficiently.

2. If the data is **not** time series, or you need data associated with a Losant Device or Experience Users, you can store it in a Data Table.

A note on the JSON Template, from this:

> I know that there are two other input options to set a device state called “JSON Template” that seems to be taking only manual entry values and “Payload Path” that seems to be taking only linear (n-1 depth) payload JSON. It does not seem to be handy for storing JSON-complex states of devices and moreover extracting it for processing later on.

These, can allow you to set all of these in one place, and access nested values and arrays:

```auto
{
  "attr1": "{{data.some.nested.value.[4].array.value}}",
  "attr2": "{{data.value }}",
}

```

There are a ton of options here:

> **[Device: State Node](https://docs.losant.com/workflows/outputs/device-state/#advanced-configuration)**
>
> The Device: State Node records telemetry data as attributes for a device.

---

_[View the full topic](https://forums.losant.com/t/storing-complex-json-payload-to-device-state-node/2034)._
