Extract data from MQTTClient DAT Help!

Hello,

I was finally able to get my data into TouchDesigner (Yay!)
Now, the issue I have been having is that I am trying to just extract the bpm value so I can focus on the live heartbeat data coming in. Does anyone have any advice, tips, suggestions on how I can just get the bpm value out of the whole row of data coming in? Please let me know, any help is greatly appreciated!!
Example of data coming in:

{"messageId":329,"sessionId":"e3abf06c-b3b9-4678-86c3-2ab695048091","deviceId":"e8ea249d-8ed5-41d8-b8c9-7ab21b56a50e","payload":[{"name":"heart rate","time":1744134818037305600,"values":{"bpm":96}}]}

TouchDesigner Workflow screenshot:

Hi @swaraich,

great to hear you were able to connect - can you post the solution to your previous question? Other’s will greatly benefit from that.

Regarding your question here. The MQTT Client DAT has a callbacks DAT attached where you can deal with the data as it is coming in. Specifically the onMessage callback is of interest.

First have a look here to see how you can retrieve values:

In your specific case it looks like you are being served a json which you would want to parse using python’s json module.
For a general introduction to TouchDesigner and Python, have a look at our curriculum, especially the section on “DATs: Scripting and Python”. It has a short Chapter on JSON parsing as well:

Hope this helps
cheers
Markus

A post was split to a new topic: Animate Circle TOP with data parsed from JSON