# Homeyscript to return a JSON

**URL:** <https://community.homey.app/t/homeyscript-to-return-a-json/109861>\
**Category:** Questions & Help\
**Tags:** homeyscript, javascript\
**Created:** [May 14, 2024, 7:02pm UTC](https://community.homey.app/t/homeyscript-to-return-a-json/109861 "2024-05-14T19:02:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin072](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martin072/32/70637_2.png) [@Martin072](https://community.homey.app/u/Martin072)\
**Post date:** [May 14, 2024, 7:02pm UTC](https://community.homey.app/t/homeyscript-to-return-a-json/109861/1 "2024-05-14T19:02:51Z")

</div>

I am trying a small homey script (see below) to return a JSON  
It does not seem to work -or accept the output as the tag is never created.

Any idea how to do this?

```auto
let devices = await Homey.devices.getDevices();
// Return array of device capabilities
await tag("homey devices", devices);
return true;

```

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [May 14, 2024, 8:42pm UTC](https://community.homey.app/t/homeyscript-to-return-a-json/109861/2 "2024-05-14T20:42:42Z")

</div>

I am not sure if you described the problem completely, as “tag” has something to do with flows and cards.  
Anyway, search the forum and find for example [Can running a script from a card create a tag?](https://community.homey.app/t/can-running-a-script-from-a-card-create-a-tag/109565)  
It gives some clues.

---

<div class="post-metadata">

**Author:** ![Martin072](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martin072/32/70637_2.png) [@Martin072](https://community.homey.app/u/Martin072)\
**Post date:** [May 14, 2024, 9:06pm UTC](https://community.homey.app/t/homeyscript-to-return-a-json/109861/3 "2024-05-14T21:06:55Z")

</div>

Yes, its a homeyscript flow card that should generate a tag with the JSON, but for some reason it doesn’t…

---

<div class="post-metadata">

**Author:** ![Rmb](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/rmb/32/79135_2.png) [@Rmb](https://community.homey.app/u/Rmb)\
**Post date:** [May 14, 2024, 9:14pm UTC](https://community.homey.app/t/homeyscript-to-return-a-json/109861/4 "2024-05-14T21:14:17Z")

</div>

That card is only avaiable in advanced flow, see link above.

---

<div class="post-metadata">

**Author:** ![Martin072](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martin072/32/70637_2.png) [@Martin072](https://community.homey.app/u/Martin072)\
**Post date:** [May 14, 2024, 9:31pm UTC](https://community.homey.app/t/homeyscript-to-return-a-json/109861/5 "2024-05-14T21:31:12Z")

</div>

Yes I know, and understand. What I don’t understand is why the script is not generating a tag with the JSON output in it

---

<div class="post-metadata">

**Author:** ![Caseda](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/caseda/32/138695_2.png) [@Caseda](https://community.homey.app/u/Caseda)\
**Post date:** [May 14, 2024, 9:44pm UTC](https://community.homey.app/t/homeyscript-to-return-a-json/109861/6 "2024-05-14T21:44:59Z")

</div>

That tag is a tag that will be like any other device capability value tag.  
If you want it returned as a string tag (advanced code flow card) then you’ll first have to first parse the JSON object to a string, and then return that string (instead of your “true”).  
If you do want it as a tag like any other device capability value, you’ll also have to parse the JSON to a string first.  
Tokens/tags just don’t accept a json object as value, either string, number or boolean.

---

<div class="post-metadata">

**Author:** ![Martin072](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/martin072/32/70637_2.png) [@Martin072](https://community.homey.app/u/Martin072)\
**Post date:** [May 14, 2024, 10:31pm UTC](https://community.homey.app/t/homeyscript-to-return-a-json/109861/7 "2024-05-14T22:31:43Z")

</div>

Thanks
