Back to Smartcitizen.me

Invalid JSON format in Kit's output payload

Hi,

The output payload of the device is not a valid JSON format.
I’ve tested it in several online JSON/JS parsers and it doesn’t pass the test in any of them.

This is what the Kit is sending as payload:
{t:2021-11-08T16:17:15Z,10:99,14:24,55:20.85…}

And this is what it should look in a valid JSON format:

{“t”:“2021-11-08T16:17:15Z”,“10”:99,“14”:24,“55”:20.85,…}

Is there a way to fix this?

Thank you!

Hi @rfernandez

Please, check what I posted here:

There are different topics the kit published. Kits running the latest firmware publishes batch data in a raw format under the topic device/sck/%s/readings/raw instead of the original device/sck/%s/readings. Raw means they push data directly from the internal flash memory without assembling a proper JSON file to save memory resources at the Kit side.

That’s the Ruby function that turns the custom data format into a valid JSON file. You can easily implement it in any other language.

You can also change the firmware to use any publishing format that you like. However, currently, we only support this one.

Hi,
Thank you very much for your answer.
I apologize, as I feel there are some underlying concepts I’m missing.

Please let me rephrase what you said to check if I understood well: and please feel free to correct me if I misunderstood anything.

  • The device changed the way it publishes information. Previous versions of the firmware published to the “…/readings” topic in JSON format. Current (latest) version of the firmware publishes to the “…/readings/raw” topic that is not formated to JSON before publishing, to save resources on the device. And, it is not publishing to the “…/readings” topic anymore.

So the readings I’ll be getting are in the form that is shown in the shell:
{t:2021-11-10T19:51:33Z,10:99,14:102,55:23.40,56:58.55,53:38.62,58:101.59,113:20.00,112:534.00}

and I will get them under the “…/readings/raw” topic in my broker.

Thank you !!

P.S. I was not able to implement mosquitto_sub -h 192.168.0.108 -p 1883 -t device/sck/+/+. For some reason I was not able to determine yet, my broker denies the subscriptions from mosquito_sub; maybe has something to do with a particular Windows configuration.