Sha256: 07a61fb33a457f83b515bbaee7d408949d087d813183b2a1ee4802b3204c6383
Contents?: true
Size: 871 Bytes
Versions: 1
Compression:
Stored size: 871 Bytes
Contents
#include <iostream> #include <nlohmann/json.hpp> using json = nlohmann::json; int main() { // create a JSON object with different entry types json j = { {"integer", 1}, {"floating", 42.23}, {"string", "hello world"}, {"boolean", true}, {"object", {{"key1", 1}, {"key2", 2}}}, {"array", {1, 2, 3}} }; // access existing values int v_integer = j.value("/integer"_json_pointer, 0); double v_floating = j.value("/floating"_json_pointer, 47.11); // access nonexisting values and rely on default value std::string v_string = j.value("/nonexisting"_json_pointer, "oops"); bool v_boolean = j.value("/nonexisting"_json_pointer, false); // output values std::cout << std::boolalpha << v_integer << " " << v_floating << " " << v_string << " " << v_boolean << "\n"; }
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
simdjson-0.3.0 | vendor/simdjson/dependencies/json/doc/examples/basic_json__value_ptr.cpp |