cancel
Showing results for 
Search instead for 
Did you mean: 

How to use JSON library in st micontrollers

Ss.61
Associate III
  • I want to use JSON library to send customized data to server
  • Where i can get the library?
  • Micro controller connected with modem (sim900a)
  • Motive is to how to send Json formatted data from st controller to server.

*My controller is :STM32F042G6

5 REPLIES 5
Sebastiaan
Senior

Hi,

JSON is more complex to parse than to construct. For constructing a fixed json string (which is what you need), snprintf() should work fine IMO.

If you need parsing, it's probably best to copy implementations like cJSON https://github.com/DaveGamble/cJSON.

Sebastiaan

Ss.61
Associate III

Than you for your quick reply once i will check & update it.

Ss.61
Associate III

Hi,

*My requirement is not parsing (incoming data) ,

*I want to use Json On Outgoing Data (From Controller)

Sebastiaan
Senior

int main()

{

 char json[20] = {0};

 char temp[] = "world";

 snprintf(json, sizeof(json), "{\"hello\": \"%s\"}", temp);

 printf("%s", json);

}

=> result is {"hello": "world"}

Understood thank you for your quick reply.