mirror of
https://github.com/nlohmann/json
synced 2024-12-26 18:41:03 +00:00
added note from http://isocpp.org/blog/2015/01/json-for-modern-cpp
This commit is contained in:
parent
f0582a8b60
commit
4f0afbbe64
@ -110,6 +110,9 @@ You can create an object (deserialization) by appending `_json` to a string lite
|
|||||||
```cpp
|
```cpp
|
||||||
// create object from string literal
|
// create object from string literal
|
||||||
json j = "{ \"pi\": 3.141, \"happy\": true }"_json;
|
json j = "{ \"pi\": 3.141, \"happy\": true }"_json;
|
||||||
|
|
||||||
|
// or even nicer (thanks http://isocpp.org/blog/2015/01/json-for-modern-cpp)
|
||||||
|
auto j2 = R"( {"pi": 3.141, "happy": true} )"_json;
|
||||||
```
|
```
|
||||||
|
|
||||||
You can also get a string representation (serialize):
|
You can also get a string representation (serialize):
|
||||||
|
@ -1775,6 +1775,10 @@ TEST_CASE("Parser")
|
|||||||
|
|
||||||
auto j3 = "{\"key\": \"value\"}"_json;
|
auto j3 = "{\"key\": \"value\"}"_json;
|
||||||
CHECK(j3["key"] == "value");
|
CHECK(j3["key"] == "value");
|
||||||
|
|
||||||
|
auto j22 = R"({"pi": 3.141, "happy": true })"_json;
|
||||||
|
auto j23 = "{ \"pi\": 3.141, \"happy\": true }"_json;
|
||||||
|
CHECK(j22 == j23);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("Errors")
|
SECTION("Errors")
|
||||||
|
Loading…
Reference in New Issue
Block a user