1
0
mirror of https://github.com/nlohmann/json.git synced 2025-07-28 12:02:00 +03:00

📝 add documentation for JSON Lines (#3247)

This commit is contained in:
Niels Lohmann
2022-01-05 09:51:29 +01:00
committed by GitHub
parent 4fc7b3dc7c
commit 6cd68ebd12
5 changed files with 118 additions and 0 deletions

View File

@ -0,0 +1,22 @@
#include <sstream>
#include <iostream>
#include <nlohmann/json.hpp>
using json = nlohmann::json;
int main()
{
// JSON Lines (see https://jsonlines.org)
std::stringstream input;
input << R"({"name": "Gilbert", "wins": [["straight", "7"], ["one pair", "10"]]}
{"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]}
{"name": "May", "wins": []}
{"name": "Deloise", "wins": [["three of a kind", "5♣"]]}
)";
std::string line;
while (std::getline(input, line))
{
std::cout << json::parse(line) << std::endl;
}
}