From 76123fab763bc32a2d7035dab26fa20815152e65 Mon Sep 17 00:00:00 2001 From: Niels Lohmann Date: Tue, 15 Aug 2017 20:49:18 +0200 Subject: [PATCH] :memo: added note wrt. #667 --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 92d1956a5..940b4ef0d 100644 --- a/README.md +++ b/README.md @@ -539,6 +539,9 @@ Some important things: * Those methods **MUST** be in your type's namespace (which can be the global namespace), or the library will not be able to locate them (in this example, they are in namespace `ns`, where `person` is defined). * When using `get()`, `your_type` **MUST** be [DefaultConstructible](http://en.cppreference.com/w/cpp/concept/DefaultConstructible). (There is a way to bypass this requirement described later.) * In function `from_json`, use function [`at()`](https://nlohmann.github.io/json/classnlohmann_1_1basic__json_a93403e803947b86f4da2d1fb3345cf2c.html#a93403e803947b86f4da2d1fb3345cf2c) to access the object values rather than `operator[]`. In case a key does not exists, `at` throws an exception that you can handle, whereas `operator[]` exhibits undefined behavior. +* In case your type contains several `operator=` definitions, code like `your_variable = your_json;` [may not compile](https://github.com/nlohmann/json/issues/667). You need to write `your_variable = your_json.get();` instead. +* You do not need to add serializers or deserializers for STL types like `std::vector`: the library already implements these. + #### How do I convert third-party types?