Skip to content

Naheel-Azawy/cppJSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cppJSON

C++ syntax sugar wrapper for cJSON.

Why?

cJSON is good, but using C++’s operation overloading makes it as easy as using Python with little added overhead. Best suited for microcontrollers. Other JSON libs are typically too big, memory intensive, or slow.

Usage

Using it is as you’d expect from a high-level json implementation. Other examples can be seen under the tests.

#include "json.hpp"

auto doc = json::obj("foo", json::obj("a", 1, "b", 2.2),
                     "bar", json::arr(1, 2, 3, 4));
doc["foo"]["c"] = "hello world";
doc["bar"][3] = json::arr("a", "b", "c");
auto doc2 = json::parse(doc.stringify());

std::cout << (doc == doc2) << std::endl;
// outputs: 1
std::cout << doc << std::endl;
// outputs: {"foo":{"a":1,"b":2.2,"c":"hello world"},"bar":[1,2,3,["a","b","c"]]}

Related projects

License

GPL3

About

C++ syntax sugar wrapper for cJSON

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published