2019-03-17 22:25:18 +01:00
|
|
|
#include <iostream>
|
2022-07-31 14:05:58 +02:00
|
|
|
#include <string_view>
|
2019-03-17 22:25:18 +01:00
|
|
|
#include <nlohmann/json.hpp>
|
|
|
|
|
2022-07-31 14:05:58 +02:00
|
|
|
using namespace std::string_view_literals;
|
2019-03-17 22:25:18 +01:00
|
|
|
using json = nlohmann::json;
|
2022-07-31 17:38:52 +02:00
|
|
|
using namespace nlohmann::literals;
|
2019-03-17 22:25:18 +01:00
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
// create some JSON values
|
|
|
|
json j_object = R"( {"key": "value"} )"_json;
|
|
|
|
json j_array = R"( [1, 2, 3] )"_json;
|
|
|
|
|
|
|
|
// call contains
|
|
|
|
std::cout << std::boolalpha <<
|
2022-07-31 14:05:58 +02:00
|
|
|
"j_object contains 'key': " << j_object.contains("key"sv) << '\n' <<
|
|
|
|
"j_object contains 'another': " << j_object.contains("another"sv) << '\n' <<
|
|
|
|
"j_array contains 'key': " << j_array.contains("key"sv) << std::endl;
|
2019-03-17 22:25:18 +01:00
|
|
|
}
|