# Jsonata to chart when payload data has extra \[ \]

**URL:** <https://discourse.nodered.org/t/jsonata-to-chart-when-payload-data-has-extra/59532>\
**Category:** General\
**Created:** [8 March 2022 10:20 UTC](https://discourse.nodered.org/t/jsonata-to-chart-when-payload-data-has-extra/59532 "2022-03-08T10:20:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Auto351](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@Auto351](https://discourse.nodered.org/u/Auto351)\
**Post date:** [8 March 2022 10:20 UTC](https://discourse.nodered.org/t/jsonata-to-chart-when-payload-data-has-extra/59532/1 "2022-03-08T10:20:45Z")

</div>

Hello.

I'm trying to produce a Node-Red chart from SQLite.

I'm stuck on the Jsonata expression and its due to extra layer of "[]" with in the payload.

please ref to the image below.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/1/f1b315faead2cc7cdfecbfeedb6e62acf7a99621.png)

If i remove these "[]" the payload is transformed correctly.

Can any advise how to account for this nested data in the jsonata expression.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 March 2022 10:25 UTC](https://discourse.nodered.org/t/jsonata-to-chart-when-payload-data-has-extra/59532/2 "2022-03-08T10:25:16Z")

</div>

Hard to test from a image, best to paste text.  
Try `$$.payload.*.[{xy object}]`  
p.s. msg is not required.

---

<div class="post-metadata">

**Author:** ![Auto351](https://avatars.discourse-cdn.com/v4/letter/a/5daacb/32.png) [@Auto351](https://discourse.nodered.org/u/Auto351)\
**Post date:** [8 March 2022 10:32 UTC](https://discourse.nodered.org/t/jsonata-to-chart-when-payload-data-has-extra/59532/3 "2022-03-08T10:32:40Z")

</div>

Thank that worked.  
when I removed the msg. it produces a blank data section, so I've left them in for now

May I ask where I can find that type of formatting for future referencing and any further nesting would need and extra "\*."

Text for future reference

{

```
   "series" :$distinct(msg.payload.POINTNAME),
   "labels" :["15 Minute"],
   "data" : $$.msg.payload.*.[
       {
"x": (TIMESTAMP),
"y": (PV) }
   ]
}

```

data  
{  
"topic": "SELECT pointname, timestamp, pv FROM 'HistoryData' WHERE pointname= 'Temp213' AND timestamp \>= '1646636665762' AND timestamp \<= '1646723065762'",  
"\_msgid": "338057f6.b75",  
"payload": [  
[  
{  
"POINTNAME": "Temp213",  
"TIMESTAMP": 1646637088491,  
"PV": 32.9  
},  
{  
"POINTNAME": "Temp213",  
"TIMESTAMP": 1646722282611,  
"PV": 29.9  
}  
]  
]  
}  
output  
{  
"series": "Temp213",  
"labels": [  
"15 Minute"  
],  
"data": [  
[  
{  
"x": 1646637088491,  
"y": 32.9  
}  
],  
[  
{  
"x": 1646722282611,  
"y": 29.9  
}  
]  
]  
}

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [8 March 2022 10:36 UTC](https://discourse.nodered.org/t/jsonata-to-chart-when-payload-data-has-extra/59532/4 "2022-03-08T10:36:23Z")

</div>

Strange, i would love to test but i am not going to type all that in.

The jsonata web page docs, is were i get all my info.  
[edit]  
with data provided the expression would be

```auto
{
   "series" :[$distinct($$.payload.POINTNAME)],
   "labels" :["15 Minute"],
   "data" : [
       [$$.payload[0].{
            "x": $.TIMESTAMP,
            "y": $.PV }
      ]
   ]
}

```

\* for one level nesting  
\*\* for all level nesting

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 March 2022 10:37 UTC](https://discourse.nodered.org/t/jsonata-to-chart-when-payload-data-has-extra/59532/5 "2022-03-22T10:37:11Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
