# Trying to use jsonata to reduce array of objects. Test data works OK but fails when deployed

**URL:** https://discourse.nodered.org/t/trying-to-use-jsonata-to-reduce-array-of-objects-test-data-works-ok-but-fails-when-deployed/68491
**Category:** General
**Created:** [2 October 2022 16:17 UTC](https://discourse.nodered.org/t/trying-to-use-jsonata-to-reduce-array-of-objects-test-data-works-ok-but-fails-when-deployed/68491 "2022-10-02T16:17:12Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![colj](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@colj](https://discourse.nodered.org/u/colj)
#### Post date: [2 October 2022 16:17 UTC](https://discourse.nodered.org/t/trying-to-use-jsonata-to-reduce-array-of-objects-test-data-works-ok-but-fails-when-deployed/68491/1 "2022-10-02T16:17:12Z")

</div>

Just started using node red. Have spent hours trying to get this to work! I have an array of objects which have entries for the next 72 hours ( JSON data from Solcast for PV forecasting) I'm only interested in tomorrows so using jsonata to just pick out those using the date. I have used test data in the node (copied from debug) and all looks fine. However, when I deploy and execute the node it always returns an empty object. Hopefully the screen shot shows the details, but the jsonata is:  
{  
"tomorrows PV forecast" :  
msg.\* [  
$contains(  
period\_end,  
$fromMillis(  
$millis()+1000_60_60\*24,  
'[Y0001]-[M01]-[D01]'  
)  
)  
]  
}

 ![Screenshot (22)](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/0/000ed14be21875b5f088f418aab51c734bf38776.png)

---

<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: [2 October 2022 16:29 UTC](https://discourse.nodered.org/t/trying-to-use-jsonata-to-reduce-array-of-objects-test-data-works-ok-but-fails-when-deployed/68491/2 "2022-10-02T16:29:18Z")

</div>

I suspect your test data is wrong  
it should be

```auto
{
  "payload":{
    Your test data.
    }
}

```

---

<div class="post-metadata">

### Author: ![colj](https://avatars.discourse-cdn.com/v4/letter/c/c2a13f/32.png) [@colj](https://discourse.nodered.org/u/colj)
#### Post date: [2 October 2022 16:43 UTC](https://discourse.nodered.org/t/trying-to-use-jsonata-to-reduce-array-of-objects-test-data-works-ok-but-fails-when-deployed/68491/3 "2022-10-02T16:43:33Z")

</div>

thank you - i had just copied the object from the debug panel!

---

<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: [16 October 2022 16:44 UTC](https://discourse.nodered.org/t/trying-to-use-jsonata-to-reduce-array-of-objects-test-data-works-ok-but-fails-when-deployed/68491/4 "2022-10-16T16:44:05Z")

</div>

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