mirror of
https://codeberg.org/vyn/rei-json.git
synced 2025-07-02 01:43:19 +00:00
Add 'remove' methods to Object and Array + unify 'set' methods
This commit is contained in:
parent
eb5191a722
commit
fd034eff71
8 changed files with 109 additions and 26 deletions
|
@ -9,23 +9,31 @@ TEST_CASE("Stringify json") {
|
|||
.set("keyNegativeNumber", -13)
|
||||
.set("keyBooleanTrue", true)
|
||||
.set("keyBooleanFalse", false)
|
||||
.set("keyElementDeleted", true) // it will be deleted after
|
||||
.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("elementDeleted"); // it will be deleted after
|
||||
array.push("");
|
||||
array.push(true);
|
||||
array.push(false);
|
||||
array.pushNull();
|
||||
|
||||
objectJson.addObject("keyObject", std::move(obj));
|
||||
objectJson.addArray("keyArray", std::move(array));
|
||||
|
||||
objectJson.remove("keyElementDeleted");
|
||||
array.remove(2);
|
||||
|
||||
objectJson.set("keyObject", std::move(obj));
|
||||
objectJson.set("keyArray", std::move(array));
|
||||
|
||||
|
||||
std::string expectedJson = R"({
|
||||
"keyArray": [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue