1#ifndef SIMDJSON_JSONPATHUTIL_H
2#define SIMDJSON_JSONPATHUTIL_H
5#include "simdjson/common_defs.h"
19 if (!json_path.empty() && json_path.front() ==
'$') {
22 if (i >= json_path.size() || (json_path[i] !=
'.' &&
23 json_path[i] !=
'[')) {
30 result.reserve(json_path.size() * 2);
32 while (i < json_path.length()) {
33 if (json_path[i] ==
'.') {
35 }
else if (json_path[i] ==
'[') {
38 while (i < json_path.length() && json_path[i] !=
']') {
39 if (json_path[i] ==
'~') {
41 }
else if (json_path[i] ==
'/') {
44 result += json_path[i];
48 if (i == json_path.length() || json_path[i] !=
']') {
52 if (json_path[i] ==
'~') {
54 }
else if (json_path[i] ==
'/') {
57 result += json_path[i];
66inline std::pair<std::string_view, std::string_view> get_next_key_and_json_path(std::string_view& json_path) {
69 if (json_path.empty()) {
70 return {key, json_path};
75 if (json_path.front() ==
'$') {
80 if (i < json_path.length() && json_path[i] ==
'.') {
84 while (i < json_path.length() && json_path[i] !=
'[' && json_path[i] !=
'.') {
88 key = json_path.substr(key_start, i - key_start);
89 }
else if ((i+1 < json_path.size()) && json_path[i] ==
'[' && (json_path[i+1] ==
'\'' || json_path[i+1] ==
'"')) {
92 while (i < json_path.length() && json_path[i] !=
'\'' && json_path[i] !=
'"') {
96 key = json_path.substr(key_start, i - key_start);
99 }
else if ((i+2 < json_path.size()) && json_path[i] ==
'[' && json_path[i+1] ==
'*' && json_path[i+2] ==
']') {
105 return std::make_pair(key, json_path.substr(i));
The top level simdjson namespace, containing everything the library provides.
std::string json_path_to_pointer_conversion(std::string_view json_path)
Converts JSONPath to JSON Pointer.