I'm attempting to send JSON data over MQTT and have the M5 load the different key values into labels. I haven't been successful trying it a few different ways. I think part of the problem is that a b' gets added to the beginning of both the topic an message values received by the MQTT software.
For reference, here is the updateProject function called:
![updatge_project.png](/assets/uploads/files/1727467391301-updatge_project.png)
And here is the JSON string i'm sending over MQTT:
{ "id": 00004578, "shape": "hex", "total": 856, "cut1": 230, "cut2": 184, "cut3": 207, "cut4": 156, "cut5": 143, "clr1": 230, "clr2": 184, "clr3": 207, "clr4": 156, "clr5": 143 }
First try was this way:
![simple_load.png](/assets/uploads/files/1727467138336-simple_load.png)
This give me an error at the line of code in the updateProject function assigning the first label value to the appropriate key/value:
TypeError: object with buffer protocol required
The second way was to remove the leading b' that gets inserted (if anyone has a better way to do this, please lmk)
![remov_b_load.png](/assets/uploads/files/1727467555944-remov_b_load.png)
This gives me an error at the line where it sets projDetails in the MQTT event:
ValueError: syntax error in JSON
The third and fourth way was trying the Dump JSON block alone and trying to remove the b'
![dump_simple.png](/assets/uploads/files/1727467947340-dump_simple.png)
![dump_complex.png](/assets/uploads/files/1727468637371-dump_complex.png)
Both cases gives the error in the first line of the updateProject function where setting the first label
TypeError: string indices must be integers, not str
Then I tried just making the variable the data minus any JSON blocks and put it off to the function to do all the work
![no_json.png](/assets/uploads/files/1727469500453-no_json.png)
This give me an error at the line of code in the updateProject function assigning the first label value to the appropriate key/value:
ValueError: syntax error in JSON
Not sure how to proceed on this. Any help would be greatly appreciated.