# How to get number from string mqtt tag?

**URL:** <https://forum.inductiveautomation.com/t/how-to-get-number-from-string-mqtt-tag/74810>\
**Category:** Ignition\
**Created:** [June 9, 2023, 6:19am UTC](https://forum.inductiveautomation.com/t/how-to-get-number-from-string-mqtt-tag/74810 "2023-06-09T06:19:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Filip\_123](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@Filip\_123](https://forum.inductiveautomation.com/u/Filip_123)\
**Post date:** [June 9, 2023, 6:19am UTC](https://forum.inductiveautomation.com/t/how-to-get-number-from-string-mqtt-tag/74810/1 "2023-06-09T06:19:34Z")

</div>

Hi,  
how can I get temperature data from string tag (temperature:100). I need temperature in celsius.  
Thanks for the answer.  
 ![Zajeta slika](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/2/528da8f9ec61d0e5afae27e0e64a816606b0a6f7.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 9, 2023, 10:40am UTC](https://forum.inductiveautomation.com/t/how-to-get-number-from-string-mqtt-tag/74810/2 "2023-06-09T10:40:53Z")

</div>

Just for clarification, you're able to get the value `{"id":100, "tC":24.1, "tF":75.4}`, but it's a string?

...or are you having trouble reading the tag itself?

---

<div class="post-metadata">

**Author:** ![Filip\_123](https://avatars.discourse-cdn.com/v4/letter/f/4491bb/32.png) [@Filip\_123](https://forum.inductiveautomation.com/u/Filip_123)\
**Post date:** [June 9, 2023, 10:52am UTC](https://forum.inductiveautomation.com/t/how-to-get-number-from-string-mqtt-tag/74810/3 "2023-06-09T10:52:59Z")

</div>

That's right I get the value but it's string.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 9, 2023, 11:50am UTC](https://forum.inductiveautomation.com/t/how-to-get-number-from-string-mqtt-tag/74810/4 "2023-06-09T11:50:54Z")

</div>

I put your displayed value into a string tag, and I was able to bind the desired value with the following expression:

```auto
jsonGet({[Sample_Tags]Writeable/temperature:100}, "tC")

```

Obviously, you'll have to replace `{[Sample_Tags]Writeable/temperature:100}` with your tag path, but otherwise [jsonGet](https://docs.inductiveautomation.com/display/DOC80/jsonGet) should work.  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/6/7/6775507d92fdbefc7468925ebc65aff4881eda2e.png)

**Result:**  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/2/82557e10ce125d1e9155c1fbbfca8e6f31eedc1a.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/4/2491d3964bb4f457493ef95db19832b1c1d5b966.png)

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [June 9, 2023, 12:04pm UTC](https://forum.inductiveautomation.com/t/how-to-get-number-from-string-mqtt-tag/74810/5 "2023-06-09T12:04:52Z")

</div>

If you need this via script, I was able to get the Celsius value in the following way:

```auto
temperatureTagValue = system.tag.readBlocking(["[Sample_Tags]Writeable/temperature:100"])[0].value
temperatureData = system.util.jsonDecode(temperatureTagValue)
celsiusValue = temperatureData["tC"]

```

---

<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:** [June 9, 2023, 3:50pm UTC](https://forum.inductiveautomation.com/t/how-to-get-number-from-string-mqtt-tag/74810/6 "2023-06-09T15:50:54Z")

</div>

Consider a derived tag with `jsonGet` and `jsonSet` if you want bidirectional support.
