# Syntax JSON Function

**URL:** https://discourse.nodered.org/t/syntax-json-function/64360
**Category:** General
**Tags:** node-red-dashboard, function-node
**Created:** [25 June 2022 13:53 UTC](https://discourse.nodered.org/t/syntax-json-function/64360 "2022-06-25T13:53:27Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![cyrillschuerch](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@cyrillschuerch](https://discourse.nodered.org/u/cyrillschuerch)
#### Post date: [25 June 2022 13:53 UTC](https://discourse.nodered.org/t/syntax-json-function/64360/1 "2022-06-25T13:53:27Z")

</div>

Hello Guys

Once again I get some problems with the function-syntax. I would like to specify the options for the dropdown node with using variable. (See photo)

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

Can you give me a tip?

Thanks a lot!

---

<div class="post-metadata">

### Author: ![mickym2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/mickym2/32/36128_2.png) [@mickym2](https://discourse.nodered.org/u/mickym2)
#### Post date: [25 June 2022 15:59 UTC](https://discourse.nodered.org/t/syntax-json-function/64360/2 "2022-06-25T15:59:30Z")

</div>

The property name should not be in quotes to create the object. You can stringify the object or define as a string.

---

<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 2022 16:50 UTC](https://discourse.nodered.org/t/syntax-json-function/64360/3 "2022-06-25T16:50:51Z")

</div>

> [@cyrillschuerch](#):
>
> Can you give me a tip?

In the Line 3, it looks like you are trying to make an array of objects where the objects `key` is from `global` context.

This is a JavaScript thing - to use a variable value as a key name in an object, you must surround it with `[]`

e.g.

```auto
var keyName = "abc"
var value = 123
var newObj = { [keyName] : value }
// makes { "abc" : 123 }

```

---

<div class="post-metadata">

### Author: ![cyrillschuerch](https://avatars.discourse-cdn.com/v4/letter/c/848f3c/32.png) [@cyrillschuerch](https://discourse.nodered.org/u/cyrillschuerch)
#### Post date: [3 July 2022 11:26 UTC](https://discourse.nodered.org/t/syntax-json-function/64360/4 "2022-07-03T11:26:19Z")

</div>

Exactly what i need, thanks!

---

<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: [17 July 2022 11:26 UTC](https://discourse.nodered.org/t/syntax-json-function/64360/5 "2022-07-17T11:26:23Z")

</div>

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