mirror of
https://github.com/nlohmann/json.git
synced 2026-04-07 00:28:56 +00:00
deploy: e90c860d53
This commit is contained in:
14
examples/value__return_type.cpp
Normal file
14
examples/value__return_type.cpp
Normal file
@@ -0,0 +1,14 @@
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
json j = json::parse(R"({"uint64": 18446744073709551615})");
|
||||
|
||||
std::cout << "operator[]: " << j["uint64"] << '\n'
|
||||
<< "default value (int): " << j.value("uint64", 0) << '\n'
|
||||
<< "default value (uint64_t): " << j.value("uint64", std::uint64_t(0)) << '\n'
|
||||
<< "explict return value type: " << j.value<std::uint64_t>("uint64", 0) << '\n';
|
||||
}
|
||||
4
examples/value__return_type.output
Normal file
4
examples/value__return_type.output
Normal file
@@ -0,0 +1,4 @@
|
||||
operator[]: 18446744073709551615
|
||||
default value (int): -1
|
||||
default value (uint64_t): 18446744073709551615
|
||||
explict return value type: 18446744073709551615
|
||||
Reference in New Issue
Block a user