simplified flatten/unflatten examples
This commit is contained in:
parent
a21f8b0c77
commit
ea84a85b13
7 changed files with 5 additions and 25 deletions
|
@ -449,7 +449,7 @@ $ make
|
||||||
$ ./json_unit "*"
|
$ ./json_unit "*"
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
All tests passed (3344554 assertions in 31 test cases)
|
All tests passed (5568699 assertions in 31 test cases)
|
||||||
```
|
```
|
||||||
|
|
||||||
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).
|
For more information, have a look at the file [.travis.yml](https://github.com/nlohmann/json/blob/master/.travis.yml).
|
||||||
|
|
|
@ -20,18 +20,11 @@ int main()
|
||||||
{
|
{
|
||||||
"object", {
|
"object", {
|
||||||
{"currency", "USD"},
|
{"currency", "USD"},
|
||||||
{"value", 42.99},
|
{"value", 42.99}
|
||||||
{"", "empty string"},
|
|
||||||
{"/", "slash"},
|
|
||||||
{"~", "tilde"},
|
|
||||||
{"~1", "tilde1"}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// call flatten()
|
// call flatten()
|
||||||
std::cout << std::setw(4) << j.flatten() << '\n';
|
std::cout << std::setw(4) << j.flatten() << '\n';
|
||||||
|
|
||||||
// flatten for a primitive value
|
|
||||||
std::cout << j["pi"].flatten() << '\n';
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/skGi8b32VhI8HOgV"><b>online</b></a>
|
<a target="_blank" href="http://melpon.org/wandbox/permlink/OZG9sHcJCXsScNiy"><b>online</b></a>
|
|
@ -6,12 +6,7 @@
|
||||||
"/list/2": 2,
|
"/list/2": 2,
|
||||||
"/name": "Niels",
|
"/name": "Niels",
|
||||||
"/nothing": null,
|
"/nothing": null,
|
||||||
"/object/": "empty string",
|
|
||||||
"/object/currency": "USD",
|
"/object/currency": "USD",
|
||||||
"/object/value": 42.99,
|
"/object/value": 42.99,
|
||||||
"/object/~0": "tilde",
|
|
||||||
"/object/~01": "tilde1",
|
|
||||||
"/object/~1": "slash",
|
|
||||||
"/pi": 3.141
|
"/pi": 3.141
|
||||||
}
|
}
|
||||||
{"":3.141}
|
|
||||||
|
|
|
@ -14,12 +14,8 @@ int main()
|
||||||
{"/list/2", 2},
|
{"/list/2", 2},
|
||||||
{"/name", "Niels"},
|
{"/name", "Niels"},
|
||||||
{"/nothing", nullptr},
|
{"/nothing", nullptr},
|
||||||
{"/object/", "empty string"},
|
|
||||||
{"/object/currency", "USD"},
|
{"/object/currency", "USD"},
|
||||||
{"/object/value", 42.99},
|
{"/object/value", 42.99},
|
||||||
{"/object/~0", "tilde"},
|
|
||||||
{"/object/~01", "tilde1"},
|
|
||||||
{"/object/~1", "slash"},
|
|
||||||
{"/pi", 3.141}
|
{"/pi", 3.141}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
<a target="_blank" href="http://melpon.org/wandbox/permlink/ITqCZsXmi0I7KGYy"><b>online</b></a>
|
<a target="_blank" href="http://melpon.org/wandbox/permlink/m2UmItixDxnYs1Se"><b>online</b></a>
|
|
@ -11,12 +11,8 @@
|
||||||
"name": "Niels",
|
"name": "Niels",
|
||||||
"nothing": null,
|
"nothing": null,
|
||||||
"object": {
|
"object": {
|
||||||
"": "empty string",
|
|
||||||
"/": "slash",
|
|
||||||
"currency": "USD",
|
"currency": "USD",
|
||||||
"value": 42.99,
|
"value": 42.99
|
||||||
"~": "tilde",
|
|
||||||
"~1": "tilde1"
|
|
||||||
},
|
},
|
||||||
"pi": 3.141
|
"pi": 3.141
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue