mirror of
https://github.com/nlohmann/json.git
synced 2024-07-15 19:05:46 +02:00
As I learned in https://github.com/melpon/wandbox/issues/209, this library is already installed at Wandbox, so we need to adjust the examples to use `#include "json.hpp"` insteas of `#include <json.hpp>`.
20 lines
518 B
C++
20 lines
518 B
C++
#include "json.hpp"
|
|
|
|
using json = nlohmann::json;
|
|
|
|
int main()
|
|
{
|
|
// create a JSON object
|
|
json j_object = {{"one", 1}, {"two", 2}};
|
|
|
|
// call find
|
|
auto it_two = j_object.find("two");
|
|
auto it_three = j_object.find("three");
|
|
|
|
// print values
|
|
std::cout << std::boolalpha;
|
|
std::cout << "\"two\" was found: " << (it_two != j_object.end()) << '\n';
|
|
std::cout << "value at key \"two\": " << *it_two << '\n';
|
|
std::cout << "\"three\" was found: " << (it_three != j_object.end()) << '\n';
|
|
}
|