# How to escape square bracket in rules

**URL:** <https://community.openhab.org/t/how-to-escape-square-bracket-in-rules/15919>\
**Category:** Scripts & Rules\
**Created:** [October 29, 2016, 4:16pm UTC](https://community.openhab.org/t/how-to-escape-square-bracket-in-rules/15919 "2016-10-29T16:16:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![illxi](https://community.openhab.org/letter_avatar_proxy/v4/letter/i/8dc957/32.png) [@illxi](https://community.openhab.org/u/illxi)\
**Post date:** [October 29, 2016, 4:16pm UTC](https://community.openhab.org/t/how-to-escape-square-bracket-in-rules/15919/1 "2016-10-29T16:16:48Z")

</div>

In my rule I try to send {“id”:1,“method”:“toggle”,“params”:} to my TCP helper item, the square brackets never got passed. I try to escape them using [ , \[, \u005B, but with no luck. on my sitemap, it just showed {“id”:1,“method”:“toggle”,“params”:}. Just wondering what is the right way to do this

Item

```auto
String yhelper "command: [%s]" {tcp=">[192.168.2.230:55443:default]" }

```

my rule

```auto
sendCommand( yhelper, "{\"id\":2,\"method\":\"toggle\",\"params\": [] }" )

```

---

<div class="post-metadata">

**Author:** ![watou](https://community.openhab.org/user_avatar/community.openhab.org/watou/32/70595_2.png) [@watou](https://community.openhab.org/u/watou)\
**Post date:** [October 29, 2016, 4:20pm UTC](https://community.openhab.org/t/how-to-escape-square-bracket-in-rules/15919/2 "2016-10-29T16:20:49Z")

</div>

In JSON, `[]` means “array”. If you want a string that is `[]`, then specify a string like `"[]"`.

---

<div class="post-metadata">

**Author:** ![illxi](https://community.openhab.org/letter_avatar_proxy/v4/letter/i/8dc957/32.png) [@illxi](https://community.openhab.org/u/illxi)\
**Post date:** [October 29, 2016, 4:24pm UTC](https://community.openhab.org/t/how-to-escape-square-bracket-in-rules/15919/3 "2016-10-29T16:24:26Z")

</div>

what I want to send is exactly that json with an empty array for “params”

---

<div class="post-metadata">

**Author:** ![watou](https://community.openhab.org/user_avatar/community.openhab.org/watou/32/70595_2.png) [@watou](https://community.openhab.org/u/watou)\
**Post date:** [October 29, 2016, 4:43pm UTC](https://community.openhab.org/t/how-to-escape-square-bracket-in-rules/15919/4 "2016-10-29T16:43:31Z")

</div>

Sorry I didn’t read more carefully. Your literal string `"{\"id\":2,\"method\":\"toggle\",\"params\": [] }"` ought to have worked. Could you verify in your events.log that the square brackets weren’t sent, as opposed to an issue with the user interface not showing them?

---

<div class="post-metadata">

**Author:** ![illxi](https://community.openhab.org/letter_avatar_proxy/v4/letter/i/8dc957/32.png) [@illxi](https://community.openhab.org/u/illxi)\
**Post date:** [November 7, 2016, 6:09am UTC](https://community.openhab.org/t/how-to-escape-square-bracket-in-rules/15919/5 "2016-11-07T06:09:16Z")

</div>

Sorry for the late reply. I double checked the log file, the square brackets did send. I was the user interface didn’t have them displayed.

---

<div class="post-metadata">

**Author:** ![watou](https://community.openhab.org/user_avatar/community.openhab.org/watou/32/70595_2.png) [@watou](https://community.openhab.org/u/watou)\
**Post date:** [November 7, 2016, 8:36am UTC](https://community.openhab.org/t/how-to-escape-square-bracket-in-rules/15919/6 "2016-11-07T08:36:09Z")

</div>

Thanks for the reply! If you wouldn’t mind opening an issue against the UI(s) that stripped off the square brackets, it would be helpful. Thanks in any case for posting back here.
