mirror of
https://github.com/nlohmann/json.git
synced 2026-10-15 10:47:13 +00:00
deploy: 40a62947d3
This commit is contained in:
1 parent
79119509a9
commit
22fba27145
555 files changed
+17342
-1394
No files matched your search
+21
-2
@@ -26,13 +26,32 @@ parsing an object of `n` keys costs O(n²) rather than O(n log n). See
|
||||
The example below demonstrates how `ordered_json` preserves the insertion order of object keys.
|
||||
|
||||
```cpp
|
||||
--8<-- "examples/ordered_json.cpp"
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using ordered_json = nlohmann::ordered_json;
|
||||
|
||||
int main()
|
||||
{
|
||||
ordered_json j;
|
||||
j["one"] = 1;
|
||||
j["two"] = 2;
|
||||
j["three"] = 3;
|
||||
|
||||
std::cout << j.dump(2) << '\n';
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Output:
|
||||
|
||||
```json
|
||||
--8<-- "examples/ordered_json.output"
|
||||
{
|
||||
"one": 1,
|
||||
"two": 2,
|
||||
"three": 3
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
## See also
|
||||
|
||||
Reference in new issue
Block a user