File: ondemand_log_tests.cpp

package info (click to toggle)
simdjson 4.2.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 27,936 kB
  • sloc: cpp: 171,612; ansic: 19,122; sh: 1,126; python: 842; makefile: 47; ruby: 25; javascript: 13
file content (30 lines) | stat: -rw-r--r-- 904 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#define SIMDJSON_VERBOSE_LOGGING 1
#include "simdjson.h"

#include <iostream>
#include <vector>
#include <string>

using namespace simdjson;


int main() {
#if SIMDJSON_EXCEPTIONS
  auto cars_json = R"( [
		{ "make": "Toyota", "model": "Camry",  "year": 2018, "tire_pressure": [ 40.1, 39.9, 37.7, 40.4 ] },
		{ "make": "Kia",    "model": "Soul",   "year": 2012, "tire_pressure": [ 30.1, 31.0, 28.6, 28.7 ] },
		{ "make": "Toyota", "model": "Tercel", "year": 1999, "tire_pressure": [ 29.8, 30.0, 30.2, 30.5 ] }
	] )"_padded;
  ondemand::parser parser;
  ondemand::document doc = parser.iterate(cars_json);
  std::vector<std::string> container;
  for(ondemand::object o : doc) {
    container.emplace_back(std::string_view(o["make"]));
  }
  std::cout << "---" << std::endl;
  for(std::string& m : container) {
    std::cout << m << std::endl;
  }
#endif // #if SIMDJSON_EXCEPTIONS
  return EXIT_SUCCESS;
}