Hello,
I’m trying to figure out something that seems easy but I haven’t understood how to do or even if it is a possible use case.
Considering a table like this:
How to create a JSON array of dictionaries that would look like (don’t mind the lack of quotes):
[{Code:1,Name:A,Quantity:10, Status: OK},{Code:2, Name: B, Quantity 11, Status: OK},{Code:3, Name: C, Quantity 20, Status: OK}, {Code: 4, Name: D, Quantity: 0, Status: NOK}]
I wanted to Publish this array to the MQTT broker.
Tizian
December 13, 2022, 8:09am
2
Hello Marioishikawa,
You can achivie this using the DICTIONARY() function and setting the second parameter to TRUE.
So: =DICTIONARY(A1:C5,TRUE)
Is that what you wanted to achieve?
Yes Tizian!
Thank you very much! One other question: I created a MQTT transmitter and a consumer on another sheet to test.
On the consuming sheet, how can I bring the results back in the same format, with keys on the first row followed by the content on each subsequent row?
Tizian
December 13, 2022, 12:53pm
4
You can use the Direction parameter of your READ() and set it to FALSE
e.g. =READ(INBOXDATA(,“Test”),M4:V12,“Dictionary”,FALSE,TRUE)
1 Like
Awesome again! Thank you!