# Create JSON from tags

**URL:** <https://forum.inductiveautomation.com/t/create-json-from-tags/72813>\
**Category:** Ignition\
**Created:** [April 24, 2023, 9:37am UTC](https://forum.inductiveautomation.com/t/create-json-from-tags/72813 "2023-04-24T09:37:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Franz\_Loschenberger](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/franz_loschenberger/32/42499_2.png) [@Franz\_Loschenberger](https://forum.inductiveautomation.com/u/Franz_Loschenberger)\
**Post date:** [April 24, 2023, 9:37am UTC](https://forum.inductiveautomation.com/t/create-json-from-tags/72813/1 "2023-04-24T09:37:55Z")

</div>

We're in love with Ignition! Great work,

However, we miss a **straightforward way to create JSON from OPC/memory tags.**  
[Where: key = tag\_name and value = value]

We use JSON to connect to our MES. A flat UDT is used, which we'll iterate over.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 24, 2023, 12:08pm UTC](https://forum.inductiveautomation.com/t/create-json-from-tags/72813/2 "2023-04-24T12:08:27Z")

</div>

Presumably, you have the names (as tagpaths) in list form. It is a one-liner to get the corresponding values. It is another one-liner to make a key-value dictionary. Like so:

```auto
tagValues = [qv.value for qv in system.readBlocking(tagPaths)]
tagDict = dict(zip([path.split('/')[-1] for path in tagPaths], tagValues)

```

From there, it is one more to use the [system.util.jsonEncode()](https://docs.inductiveautomation.com/display/DOC81/system.util.jsonEncode) function. Though the latter can be omitted if you submit the dictionary as a json argument to `httpClient`.

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [April 24, 2023, 1:40pm UTC](https://forum.inductiveautomation.com/t/create-json-from-tags/72813/3 "2023-04-24T13:40:02Z")

</div>

It's not every day you get to fix something from Phil !

```python
tagValues = [qv.value for qv in system.tag.readBlocking(tagPaths)]
tagDict = dict(zip([path.split('/')[-1] for path in tagPaths], tagValues))

```

Fixed call to `system.tag.readBlocking` and missing parenthesis at the end.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 24, 2023, 1:45pm UTC](https://forum.inductiveautomation.com/t/create-json-from-tags/72813/4 "2023-04-24T13:45:23Z")

</div>

> [@pascal.fragnoud](#):
>
> fix something from Phil

Just testing the audience... _ **\* cough \*** _

---

<div class="post-metadata">

**Author:** ![Steve\_Laubach](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/steve_laubach/32/60900_2.png) [@Steve\_Laubach](https://forum.inductiveautomation.com/u/Steve_Laubach)\
**Post date:** [April 24, 2023, 2:07pm UTC](https://forum.inductiveautomation.com/t/create-json-from-tags/72813/5 "2023-04-24T14:07:04Z")

</div>

You can also right click on a tag or folder and select "Copy JSON" and paste that into a text editor.

Export works the same way.

Depending on your situation either method may be ideal.

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [March 25, 2024, 9:06pm UTC](https://forum.inductiveautomation.com/t/create-json-from-tags/72813/6 "2024-03-25T21:06:16Z")

</div>

Split this topic on March 25, 2024, 9:06pm UTC

2 posts were merged into an existing topic: [Create JSON Message format from tags](https://forum.inductiveautomation.com/t/create-json-message-format-from-tags/87868/3)
