# Pass array to TypedInput type "json"

**URL:** https://discourse.nodered.org/t/pass-array-to-typedinput-type-json/47608
**Category:** Developing Nodes
**Created:** [24 June 2021 21:39 UTC](https://discourse.nodered.org/t/pass-array-to-typedinput-type-json/47608 "2021-06-24T21:39:10Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [24 June 2021 21:39 UTC](https://discourse.nodered.org/t/pass-array-to-typedinput-type-json/47608/1 "2021-06-24T21:39:11Z")

</div>

Hi folks,

I have a TypedInput of type "json", and I pass a default array to it:

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

But when I open the JSON editor, the array is considered incorrect:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/b/8b656e1175ad441b482a5b0472c06e46b1120346.png)

So the quotes and rectangular brackets are gone.  
Must be something stupid, but need a fresh pair of eyes to look at this code snippet ...

Thanks !!  
Bart

---

<div class="post-metadata">

### Author: ![Hypnos](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hypnos/32/7566_2.png) [@Hypnos](https://discourse.nodered.org/u/Hypnos)
#### Post date: [24 June 2021 22:21 UTC](https://discourse.nodered.org/t/pass-array-to-typedinput-type-json/47608/2 "2021-06-24T22:21:15Z")

</div>

Is as the value really a Javascript object allowed or only a stringified JSON?

---

<div class="post-metadata">

### Author: ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)
#### Post date: [24 June 2021 22:38 UTC](https://discourse.nodered.org/t/pass-array-to-typedinput-type-json/47608/3 "2021-06-24T22:38:08Z")

</div>

If the type is JSON, then it expects it's value to be a JSON string, not a JavaScript array

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [25 June 2021 18:09 UTC](https://discourse.nodered.org/t/pass-array-to-typedinput-type-json/47608/4 "2021-06-25T18:09:37Z")

</div>

@Hypnos,  
I was wondering the same thing last night, because the name "json" already tells everything. But since Node-RED is Javascript objects all over the place, I thought that it had to be a Javascript array (and me using it somehow incorrectly)...  
And I was so sure that I already had used it before, but couldn't find anything...

@knolleary: thanks for the explanation and confirmation!

If anybody is ever searching for it:

- Set the "json" typedInput value:

```auto
myInputField.typedInput("value", JSON.stringify(value || []));

```

- Get the "json" typedInput value:

```auto
var value = JSON.parse(myInputField.typedInput('value'));

```

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [25 June 2021 18:25 UTC](https://discourse.nodered.org/t/pass-array-to-typedinput-type-json/47608/5 "2021-06-25T18:25:14Z")

</div>

> [@BartButenaers](#):
>
> Get the "json" typedInput value:
> 
> ```auto
> var value = JSON.parse(myInputField.typedInput('value'));
> 
> ```

Not really Bart, you should use `RED.util.evaluateNodeProperty` which will parse the JSON according.

---

<div class="post-metadata">

### Author: ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)
#### Post date: [25 June 2021 18:35 UTC](https://discourse.nodered.org/t/pass-array-to-typedinput-type-json/47608/6 "2021-06-25T18:35:02Z")

</div>

Ah yes Steve,  
That is why I couldn't find it anymore. After a heavy day at work completely forgotten about that one...  
Every time I look at that functions parameters, I always have to remind myself whether this is used for node or msg fields or both.

---

<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: [9 July 2021 18:35 UTC](https://discourse.nodered.org/t/pass-array-to-typedinput-type-json/47608/7 "2021-07-09T18:35:59Z")

</div>

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