mirror of
https://codeberg.org/vyn/rei-json.git
synced 2025-07-01 17:43:18 +00:00
44 lines
888 B
Markdown
44 lines
888 B
Markdown
# rei-cpp
|
|
> [!warning]
|
|
> This is a work in progress, not stable and the API might change.
|
|
|
|
A C++ JSON library.
|
|
|
|
## Example
|
|
|
|
```cpp
|
|
#include "rei-json/json.h"
|
|
#include <print>
|
|
|
|
int main() {
|
|
auto objectJson = rei::json::JsonObject{};
|
|
objectJson
|
|
.set("keyPositiveNumber", 12)
|
|
.set("keyNegativeNumber", -13)
|
|
.set("keyBooleanTrue", true)
|
|
.set("keyBooleanFalse", false)
|
|
.set("keyString", "YEP")
|
|
.set("keyEmptyString", "")
|
|
.setNull("keyNull");
|
|
|
|
rei::json::JsonObject obj{};
|
|
obj.set("keyNumberOnObject", 42);
|
|
|
|
rei::json::JsonArray array{};
|
|
array.push(42);
|
|
array.push("elemString");
|
|
array.push("");
|
|
array.push(true);
|
|
array.push(false);
|
|
array.pushNull();
|
|
|
|
objectJson.addObject("keyObject", std::move(obj));
|
|
objectJson.addArray("keyArray", std::move(array));
|
|
|
|
auto newJsonString = rei::json::toString(objectJson);
|
|
std::println("{}\n", newJsonString);
|
|
|
|
return 0;
|
|
}
|
|
```
|
|
|