# Performant way to get JSON or XML from tags

**URL:** <https://forum.inductiveautomation.com/t/performant-way-to-get-json-or-xml-from-tags/68476>\
**Category:** Ignition\
**Created:** [January 11, 2023, 11:19am UTC](https://forum.inductiveautomation.com/t/performant-way-to-get-json-or-xml-from-tags/68476 "2023-01-11T11:19:27Z")\
**Posts on this page:** 3\
**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:** [January 11, 2023, 11:19am UTC](https://forum.inductiveautomation.com/t/performant-way-to-get-json-or-xml-from-tags/68476/1 "2023-01-11T11:19:27Z")

</div>

Are there recommendations for creating XML or JSON _from tag values_?

**Background:** For connecting machines to our MES, we use an API that accepts events (machine cycles, process & piece data...) in these formats.

**What we have done so far (=our concept):** We created UDTs to reference the needed tags in Ignition. An expression tag is part of the UDT to hold the XML/JSON content. That tag is SCRIPTED. (It will refresh its XML/JSON content only when necessary — triggered in its own tag group on a rising edge trigger. Once activated, ⇒ feed a stored procedure with that expression tag value).

**My concern:** Even when the XML/JSON expression tag does only refresh when needed, the calculation might get slow once we use n different events and connect nn machines.

Is there a performant or quick way to get the JSON or XML representation of tags or tag groups (UDTs)?

Thanks for any feedback,  
Regards!  
Franz Löschenberger

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [January 11, 2023, 11:55am UTC](https://forum.inductiveautomation.com/t/performant-way-to-get-json-or-xml-from-tags/68476/2 "2023-01-11T11:55:26Z")

</div>

Consider using a gateway tag change event instead.

You may find this thead of interest:

> [@How things work - how much code is allowed behind tag event?](https://forum.inductiveautomation.com/t/how-things-work-how-much-code-is-allowed-behind-tag-event/68443):
>
> My current understanding is that tag events scripting is only meant for small code like copying the value to other tag, capturing timestamp, checking logic or arithmetic operation. My understanding is that tag events errors do not show up so can go unnoticed. So from code reliability point of view: 1 - How can i know that i didn't put too much code behind tag event? Is there a way to capture an error? 2 -if there is too much code and the next tag cycle update has to happen the unfinished code …

---

<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:** [January 11, 2023, 1:12pm UTC](https://forum.inductiveautomation.com/t/performant-way-to-get-json-or-xml-from-tags/68476/3 "2023-01-11T13:12:21Z")

</div>

Consider not using an expression tag. Simply use a single gateway tag change event script that constructs the JSON and submits it to the API. Give it a dedicated thread.
