# How do I create a json string to publish via MQTT

**URL:** <https://community.homey.app/t/how-do-i-create-a-json-string-to-publish-via-mqtt/24250>\
**Category:** Questions & Help\
**Created:** [January 11, 2020, 6:58pm UTC](https://community.homey.app/t/how-do-i-create-a-json-string-to-publish-via-mqtt/24250 "2020-01-11T18:58:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikla](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/nikla/32/18992_2.png) [@nikla](https://community.homey.app/u/nikla)\
**Post date:** [January 11, 2020, 6:58pm UTC](https://community.homey.app/t/how-do-i-create-a-json-string-to-publish-via-mqtt/24250/1 "2020-01-11T18:58:41Z")

</div>

I try to generate a json string including a sensor value which I then intend to publish via MQTT. I do not figure out how to do it. I feel a bit stupid actually. I would like to do something like this:  
`sprintf("{ 'temperature' : %s }", sensorvalue)`  
so that the string is set to e.g. `{ 'temperature' : 10 }`.  
I thought BetterLogic could help me but I fail. Is there another app that can help me?

/Niklas
