xref: /third_party/json/docs/examples/parse__pointers.cpp (revision c5f01b2f)
  • 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 string that is not null-terminated
10c5f01b2fSopenharmony_ci    const char* ptr = "[1,2,3]another value";
11c5f01b2fSopenharmony_ci
12c5f01b2fSopenharmony_ci    // parse and serialize JSON
13c5f01b2fSopenharmony_ci    json j_complete = json::parse(ptr, ptr + 7);
14c5f01b2fSopenharmony_ci    std::cout << std::setw(4) << j_complete << "\n\n";
15c5f01b2fSopenharmony_ci}
16

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