1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-29 23:01:16 +03:00

Docs: Fix wrong code usage in the Value access section of json_pointer.md (#4255)

This commit is contained in:
Fallen_Breath
2024-04-13 20:15:00 +08:00
committed by GitHub
parent 01da82eae2
commit 8c391e04fe

View File

@ -71,10 +71,10 @@ auto j = json::parse(R"({
})");
// access values
auto val = j["/"_json_pointer]; // {"array":["A","B","C"],...}
auto val = j[""_json_pointer]; // {"array":["A","B","C"],...}
auto val1 = j["/nested/one"_json_pointer]; // 1
auto val2 = j.at[json::json_pointer("/nested/three/1")]; // false
auto val3 = j.value[json::json_pointer("/nested/four", 0)]; // 0
auto val2 = j.at(json::json_pointer("/nested/three/1")); // false
auto val3 = j.value(json::json_pointer("/nested/four"), 0); // 0
```
## Flatten / unflatten