You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
552 B
28 lines
552 B
3 months ago
|
#include <iostream>
|
||
|
#include <fstream>
|
||
|
#include <fmt/core.h>
|
||
|
#include <nlohmann/json.hpp>
|
||
|
using json = nlohmann::json;
|
||
|
|
||
|
using namespace fmt;
|
||
3 months ago
|
using std::string, std::cout;
|
||
3 months ago
|
|
||
|
int main(int argc, char *argv[]) {
|
||
|
if(argc != 2) {
|
||
|
println("USAGE: jsontest [jsonfile]");
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
3 months ago
|
std::ifstream infile(argv[1]);
|
||
3 months ago
|
json data = json::parse(infile);
|
||
|
|
||
3 months ago
|
json::string_t s2 = data["happy"].template get<string>();
|
||
3 months ago
|
|
||
|
for(auto &el : data.items()) {
|
||
|
cout << el.key() << "=" << el.value() << "\n";
|
||
|
}
|
||
|
|
||
|
println("DATA HAPPY {}", s2);
|
||
|
return 0;
|
||
|
}
|