Skip to content

This repository contains a lightweight JSON serializer written in C.

Notifications You must be signed in to change notification settings

BobAaldering/JSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON serializer

This is a lightweight JSON serializer written in C. The implementation is quite lightweight, and can find application within microcontrollers, for example. In my case I have used this implementation on the ATmega328P microcontroller among others. The aim was to transmit different values of I2C sensors, whereby the values should be easily and universally deserialized.

Since a dynamic buffer is used, the first thing you need to do is call the function initialize_json_data. Then you can add tags with, for example, the function add_json_float_object. Note the use of the end_of_json parameter. If you want to name the end of a JSON object, this value must be true, otherwise false. If the JSON serializer is no longer used, you have to clear the buffer independently by calling destruct_json_data.

An application can be generated as follows:

json_data_t data;

initialize_json_data(&data);

add_json_float_object(&data, "Temperature", 34, false);
add_json_int_object(&data, "Firmware", 1, false);
add_json_str_object(&data, "SensorType", "BMP280", false);

printf("Data: %s\n", data.data_string);

destruct_json_data(&data);

About

This repository contains a lightweight JSON serializer written in C.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published