eWon Basic IDE get and command using Json format

Hi,

I would like to use Basic IDE to get Json data and command stuff in Json format.

Example is below,

{
“commandId”: 601,
“id”: 1234,
“params”: {
}
}

Is there any example to get and push json data?

Thanks,

Hi @ab_ab,

One of my colleagues just gave me some example code he had written that sends JSON data over MQTT

FormatJSON:
json$ = ‘{’
FOR i% = 1 To TagCount% THEN
json$ = json$ + ’ “’ + RTRIM(b$(i%, 1)) + '” : “’+ RTRIM(b$(i%, 2)) + '” , ’
NEXT i%
json$ = json$ + ‘“time” : "’ + @JSONTime$() + '" ’
json$ = json$ + ‘}’
MsgToPublish$ = json$
RETURN

In the example above, b$ is an array that contains a list of tags and corresponding data. The function @JSONTime$ just reads the Flexy time and converts it into a JSON friendly format.

He also sent over this site to use as a reference for JSON syntax