How to initialise single object from map and key-value pair? #3611
-
What I would like to do is something like
and have the output be |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't think that's currently possible but shouldn't be too difficult to add. std::map<std::string, int> amap{{"a key", 0}};
json j{{"some other key", 1}};
j.update(json(amap)); (Note that See https://json.nlohmann.me/api/basic_json/update/ for details. |
Beta Was this translation helpful? Give feedback.
I don't think that's currently possible but shouldn't be too difficult to add.
However, you can do the following:
(Note that
json(amap)
andjson{amap}
produce different results!)See https://json.nlohmann.me/api/basic_json/update/ for details.