json/doc/examples/operatorarray__key_type_const.cpp
Niels 4351698c83 re-adding const version operator[] (#135, #159)
It was a good idea to implement a const version of operator[] it in the
first place. I was a pity that this implementation was flawed. It was a
mistake to remove the const version completely. This commit
re-introduces the const version. My apologies for all the inconvenience.
2015-12-21 08:42:42 +01:00

16 lines
253 B
C++

#include <json.hpp>
using namespace nlohmann;
int main()
{
// create a JSON object
const json object =
{
{"one", 1}, {"two", 2}, {"three", 2.9}
};
// output element with key "two"
std::cout << object["two"] << '\n';
}