mirror of
https://github.com/nlohmann/json.git
synced 2026-10-03 07:25:20 +00:00
Merge branch 'json-view/11-view-access' into json-view/12-view-values
Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -15,7 +15,7 @@ int main()
|
||||
const auto values = measurements.root();
|
||||
|
||||
const int sum = std::accumulate(values.cbegin(), values.cend(), 0,
|
||||
[](int total, const json_view & v)
|
||||
[](int total, const json_view & v)
|
||||
{
|
||||
return total + v.materialize().get<int>();
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@ int main()
|
||||
const auto records = batch.root();
|
||||
|
||||
const bool all_objects = std::all_of(records.cbegin(), records.cend(),
|
||||
[](const json_view & v)
|
||||
[](const json_view & v)
|
||||
{
|
||||
return v.is_object();
|
||||
});
|
||||
|
||||
@@ -13,7 +13,10 @@ int main()
|
||||
json_document bad = json_document::parse("[1, 2, 3]");
|
||||
json_document failed = json_document::parse("not json", /* allow_exceptions */ false);
|
||||
|
||||
for (const json_view v : { good.root(), bad.root(), failed.root() })
|
||||
for (const json_view v :
|
||||
{
|
||||
good.root(), bad.root(), failed.root()
|
||||
})
|
||||
{
|
||||
if (v.is_object())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user