Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
nlohmann committed Jan 5, 2015
1 parent f0582a8 commit 4f0afbb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ You can create an object (deserialization) by appending `_json` to a string lite
```cpp
// create object from string literal
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):
Expand Down
4 changes: 4 additions & 0 deletions test/json_unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,10 @@ TEST_CASE("Parser")

auto j3 = "{\"key\": \"value\"}"_json;
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")
Expand Down

0 comments on commit 4f0afbb

Please sign in to comment.