# Invalid JSON from Input Block to Virtual Button to Workflow

**URL:** <https://forums.losant.com/t/invalid-json-from-input-block-to-virtual-button-to-workflow/1838>\
**Category:** Help\
**Tags:** dashboard, workflow\
**Created:** [May 30, 2019, 5:04pm UTC](https://forums.losant.com/t/invalid-json-from-input-block-to-virtual-button-to-workflow/1838 "2019-05-30T17:04:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Leo\_Bach1](https://avatars.discourse-cdn.com/v4/letter/l/ad7895/32.png) [@Leo\_Bach1](https://forums.losant.com/u/Leo_Bach1)\
**Post date:** [May 30, 2019, 5:04pm UTC](https://forums.losant.com/t/invalid-json-from-input-block-to-virtual-button-to-workflow/1838/1 "2019-05-30T17:04:34Z")

</div>

I am sending this input block’s data from a User Experience Dashboard via a virtual button to a workflow:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/9/946cf4ed6ae63406b962b60d959e6c1c26dc9d4a.png)

Full device info is shared in the dashboard in context:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/45d3febd5654afa7bd52a0a4e6535f24e0598223.png)

However when I try to submit the data it shows that the data does not end up as valid JSON:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/3/3caa9d7b60725fd7963dd2dad57c16b25dc88aba.png)

It seems {{ctx.deviceId.id}} and {{ctx.deviceId.name}} are valid JSON as they evaluate correctly everywhere else on the dashboard.

See that {{ctx.deviceId.name}} evaluates to 42003

Setting:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/c3ba32124b8bd85d4acb845e24db03ca69a6c2c9.png)  
In User Experience:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/f/f4142645dcf373e0e7e895db805ec84d23f3a293.png)

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [May 30, 2019, 6:13pm UTC](https://forums.losant.com/t/invalid-json-from-input-block-to-virtual-button-to-workflow/1838/2 "2019-05-30T18:13:15Z")

</div>

Hi Leo,

You are seeing this error as {{ctx.deviceId.tags}} is an object, and the intended use for .tags is to return just one tag, or a stringified object. The documentation states:

> `{{ctx.VARIABLE_NAME.tags}}` is a reference to the tags associated with the device; you may wish to [iterate over all tags](https://docs.losant.com/workflows/accessing-payload-data/#iterating-over-arrays-and-objects) or get the value of a specific tag with a string template such as `{{ctx.VARIABLE_NAME.tags.TAG_KEY.[INDEX]}}` , where `INDEX` is usually `0` since tag values are returned as an array.

If you would like to get the tags as an object, I would recommend doing so in the workflow. You can do this by using the deviceId you are sending in a Device: Get Node and checking the box to get return tags as an object.

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![Leo\_Bach1](https://avatars.discourse-cdn.com/v4/letter/l/ad7895/32.png) [@Leo\_Bach1](https://forums.losant.com/u/Leo_Bach1)\
**Post date:** [May 30, 2019, 6:54pm UTC](https://forums.losant.com/t/invalid-json-from-input-block-to-virtual-button-to-workflow/1838/3 "2019-05-30T18:54:10Z")

</div>

Data comes in as the device name:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/5/52f59349c42b93628d431fab1546c7fab87534af.png)

Then use the get device node to find the id and tags:  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/b4e5079e8d0bfe63e64ebc34ae93ab96e04caf12.png)

Works great, thanks!

I did however find one thing perplexing:

It works if I send the device name as such:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/c/cc69a02bb2442e8d1724a22342c9b8ca1175d2af.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/b/b131bf5358ff8f2f899882e8f63891c879790733.png)

But also shows a JSON error if i send the device id as such:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/4/470bb68d71695d68882fb9d8bc4d61784226fe93.png)  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/getstructure/original/2X/2/23406a70564ddf00da4a6c6ce4d51000f273dd8e.png)

---

<div class="post-metadata">

**Author:** ![JuliaKempf](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.losant.com/juliakempf/32/2446_2.png) [@JuliaKempf](https://forums.losant.com/u/JuliaKempf)\
**Post date:** [May 30, 2019, 7:45pm UTC](https://forums.losant.com/t/invalid-json-from-input-block-to-virtual-button-to-workflow/1838/4 "2019-05-30T19:45:01Z")

</div>

Hi Leo,

The id has to be formatted as a string to pass the JSON validator:

```auto
{ "sensor" : "{{ctx.deviceId.id}}" }

```

Thanks!  
Julia

---

<div class="post-metadata">

**Author:** ![Leo\_Bach1](https://avatars.discourse-cdn.com/v4/letter/l/ad7895/32.png) [@Leo\_Bach1](https://forums.losant.com/u/Leo_Bach1)\
**Post date:** [May 30, 2019, 7:52pm UTC](https://forums.losant.com/t/invalid-json-from-input-block-to-virtual-button-to-workflow/1838/5 "2019-05-30T19:52:45Z")

</div>

I need to pay more attention to variable types apparently. 😅  
Thanks again, Julia.
