json/docs/examples/operator_array__keytype_const.c++17.cpp

19 lines
353 B
C++
Raw Normal View History

#include <iostream>
#include <string_view>
#include <nlohmann/json.hpp>
2015-06-25 00:40:16 +02:00
using namespace std::string_view_literals;
using json = nlohmann::json;
2015-06-25 00:40:16 +02:00
int main()
{
// create a JSON object
const json object =
2015-06-25 00:40:16 +02:00
{
{"one", 1}, {"two", 2}, {"three", 2.9}
};
// output element with key "two"
std::cout << object["two"sv] << '\n';
2015-06-25 00:40:16 +02:00
}