cinder / Cinder

Cinder is a community-developed, free and open source library for professional-quality creative coding in C++.
http://libcinder.org
Other
5.28k stars 939 forks source link

JSON for Modern C++ #2286

Closed andrewfb closed 2 years ago

andrewfb commented 2 years ago

This PR supersedes the Cinder-proprietary JsonTree in favor of the widely library by Niels Lohmann, JSON for Modern C++.

For (temporary) backwards compatibility, the previous implementation is still accessible via src\cinder\JsonTree.cpp and include\cinder\JsonTree.h. This PR updates a couple of samples, as well as the Unit tests.

Note that this implementation is mostly a using statement, in the sense that the nlohmann::json is mapped to ci::Json. It also includes convenience methods for loadJson() and writeJson(), and some helpful wrappers from @num3ric that allow direct usage of some core Cinder types.

Particularly for performance-sensitive users, other libraries may be more suitable, but this inclusion in Cinder is primarily for convenience and doesn't introduce any dependencies on the underlying library (or compile time penalties) when ci::Json is not used.