Go to the documentation of this file.00001 #include <json.hpp>
00002
00003 using json = nlohmann::json;
00004
00005 int main()
00006 {
00007
00008 json j =
00009 {
00010 {"integer", 1},
00011 {"floating", 42.23},
00012 {"string", "hello world"},
00013 {"boolean", true},
00014 {"object", {{"key1", 1}, {"key2", 2}}},
00015 {"array", {1, 2, 3}}
00016 };
00017
00018
00019 int v_integer = j.value("integer", 0);
00020 double v_floating = j.value("floating", 47.11);
00021
00022
00023 std::string v_string = j.value("nonexisting", "oops");
00024 bool v_boolean = j.value("nonexisting", false);
00025
00026
00027 std::cout << std::boolalpha << v_integer << " " << v_floating
00028 << " " << v_string << " " << v_boolean << "\n";
00029 }