xref: /third_party/json/docs/examples/parse__contiguouscontainer__parser_callback_t.cpp
  • Home
  • History
  • Annotate Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
  • only in /third_party/json/docs/examples/
1c5f01b2fSopenharmony_ci#include <iostream>
2c5f01b2fSopenharmony_ci#include <iomanip>
3c5f01b2fSopenharmony_ci#include <nlohmann/json.hpp>
4c5f01b2fSopenharmony_ci
5c5f01b2fSopenharmony_ciusing json = nlohmann::json;
6c5f01b2fSopenharmony_ci
7c5f01b2fSopenharmony_ciint main()
8c5f01b2fSopenharmony_ci{
9c5f01b2fSopenharmony_ci    // a JSON text given as std::vector
10c5f01b2fSopenharmony_ci    std::vector<std::uint8_t> text = {'[', '1', ',', '2', ',', '3', ']', '\0'};
11c5f01b2fSopenharmony_ci
12c5f01b2fSopenharmony_ci    // parse and serialize JSON
13c5f01b2fSopenharmony_ci    json j_complete = json::parse(text);
14c5f01b2fSopenharmony_ci    std::cout << std::setw(4) << j_complete << "\n\n";
15c5f01b2fSopenharmony_ci}
16

Indexes created Thu Nov 07 10:32:03 CST 2024