# Custom node - how to specify json data

**URL:** <https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395>\
**Category:** Core Development\
**Created:** [25 May 2018 20:57 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395 "2018-05-25T20:57:02Z")\
**Posts on this page:** 12\
**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:** [25 May 2018 20:57 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/1 "2018-05-25T20:57:02Z")

</div>

Hi folks,

My first question on this new forum ...

I'm currently developing a new contribution to control IP devices using the OnVif protocol. For example you should be able to add new users to the IP device, which I could implement using following code snippet:

> ```
> var params = {
> 'User' : [
> {'Username': 'user1', 'Password' : 'pwd1', 'UserLevel': 'Administrator'},
> {'Username': 'user2', 'Password' : 'pwd2', 'UserLevel': 'Operator'},
> {'Username': 'user3', 'Password' : 'pwd3', 'UserLevel': 'User'}
> ]
> };
> 
> someIpDevice.createUsers(params);
> 
> ```

Since I have a lot of available actions, the **'create users'** can be selected on the config screen:

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

But what is the best way to offer those **'params'** to my node?

1. Should I provide a table on the node's config screen with an '_add user_' button (which becomes only visible when 'add users' is selected in the dropdown). But that seems a bit weird, since you need to redeploy the flow to set those new users? Or am I completely mistaken about this?
2. Should the payload of the input message contain the entire JSON.
3. Both 1 and 2 ?
4. Others ?

Thanks a lot !!!  
Bart

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 May 2018 11:16 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/2 "2018-05-26T11:16:16Z")

</div>

It has been a while since I looked at this so sorry, I’m rather rusty.

However, if you look at some of the built-in nodes, they are also building a nested dataset like yours. So the best thing to do is to find a node that requires similar settings and then copy that. I can’t think of a specific example off the top of my head, hopefully someone with a better memory will chip in. But if I think of one, I will update.

---

<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:** [26 May 2018 21:31 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/3 "2018-05-26T21:31:45Z")

</div>

Hi Julian,

Appreciate your help !!

Have been doing some homework by examing other nodes...  
I could show a list of users on the node's config screen:

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

As soon as an input message triggers this node, those specified users will be created on the OnVif-compatible IP device. _And when list of users on the config screen is empty, the input message should contain a user list in JSON format_.

P.S. When I need to pass a JSON with more levels (to the IP camera), I'm scr\*wed with this table design ...

Thanks !!  
Bart

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [28 May 2018 15:09 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/4 "2018-05-28T15:09:37Z")

</div>

I remember seeing some nodes with nested config, I just can’t remember where I’m afraid.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [28 May 2018 15:12 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/5 "2018-05-28T15:12:27Z")

</div>

Good old MQTT 😉 with TLS enabled - gives you a 2nd config for the TLS part.

---

<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:** [28 May 2018 20:52 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/6 "2018-05-28T20:52:06Z")

</div>

Hi Julian, Dave,

New forum, old acquaintances 😉

The MQTT broker config node indeed seems to have a nested config node. For anybody reading this, this is the field Dave is talking about:

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

Thanks !  
Bart

---

<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:** [4 June 2018 15:13 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/7 "2018-06-04T15:13:54Z")

</div>

Hi guys,

My Onvif implementation for Node-Red is growing, but still a lot of work. For each OnVif function, the user can select an action from a combobox, and then corresponding input fields become visible (i.e. the input for that function).

Now I need to add the **setVideoEncoder** action, which needs a lot of input:

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

1. This is the OnVif function, with options as parameter
2. The user can select a corresponding action from the combobox
3. The input fields become visible for all the (required or optional) options. For the options of depth 1 (i.e. option.xxx) this is no problem: I just show them below the combobox.
4. However some options have more than 1 level depth (options.mpeg4.profile). **_How could I visualize this? Can I have some indentation ?_**

Can't remember that I have seen other nodes with such a config screen ...

Thanks !!!!  
Bart

---

<div class="post-metadata">

**Author:** ![tilleul](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tilleul/32/78_2.png) [@tilleul](https://discourse.nodered.org/u/tilleul)\
**Post date:** [4 June 2018 16:05 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/8 "2018-06-04T16:05:35Z")

</div>

Wow ! Thanks ! I have to see how it works, I thought I read somewhere it was not possible to have a config-node within another config-node …

---

<div class="post-metadata">

**Author:** ![davidcgu](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@davidcgu](https://discourse.nodered.org/u/davidcgu)\
**Post date:** [4 June 2018 18:18 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/9 "2018-06-04T18:18:05Z")

</div>

Hi Bart,  
I’m using a camera just with the RTSP stream starting with the tutorial/flow done by Csongor at [https://www.youtube.com/watch?v=ihZWrJmbGFY&t=228s](https://www.youtube.com/watch?v=ihZWrJmbGFY&t=228s) however I just ordered a cheap NVR/onvif compatble camera and will play a bit.

Will be great if you share your job a bit when you have something so it will help other ppl like me, will be much appreciated.

Regards

---

<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:** [4 June 2018 18:52 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/10 "2018-06-04T18:52:34Z")

</div>

Hi David,

I will release the OnVif node suite as soon as it is ready. The code is at [node-red-contrib-onvif](https://github.com/bartbutenaers/node-red-contrib-onvif), but it is far from finished (missing functionality, lot of bugs, …). **It will change a lot soon, so don’t use it yet !!!** Give me a couple of weeks …

Bart

---

<div class="post-metadata">

**Author:** ![davidcgu](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@davidcgu](https://discourse.nodered.org/u/davidcgu)\
**Post date:** [4 June 2018 18:57 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/11 "2018-06-04T18:57:33Z")

</div>

Thanks a lot mate, take it easy is not urgent at all but a nice flow will guide a lot other people like me.

Regards

---

<div class="post-metadata">

**Author:** ![davidcgu](https://avatars.discourse-cdn.com/v4/letter/d/e8c25b/32.png) [@davidcgu](https://discourse.nodered.org/u/davidcgu)\
**Post date:** [14 June 2018 23:38 UTC](https://discourse.nodered.org/t/custom-node-how-to-specify-json-data/395/12 "2018-06-14T23:38:15Z")

</div>

Hey boss, remember to let me know when it’s released so I can play a bit with it if you don’t mind.

Thanks in advance
