mirror of
https://github.com/nlohmann/json.git
synced 2025-07-15 07:41:50 +03:00
Reorganize directories (#3462)
* 🚚 move files * 🚚 rename doc folder to docs * 🚚 rename test folder to tests
This commit is contained in:
18
docs/examples/count.cpp
Normal file
18
docs/examples/count.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
#include <iostream>
|
||||
#include <nlohmann/json.hpp>
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
int main()
|
||||
{
|
||||
// create a JSON object
|
||||
json j_object = {{"one", 1}, {"two", 2}};
|
||||
|
||||
// call count()
|
||||
auto count_two = j_object.count("two");
|
||||
auto count_three = j_object.count("three");
|
||||
|
||||
// print values
|
||||
std::cout << "number of elements with key \"two\": " << count_two << '\n';
|
||||
std::cout << "number of elements with key \"three\": " << count_three << '\n';
|
||||
}
|
Reference in New Issue
Block a user