29 #include <SimoxUtility/algorithm/string/string_tools.h>
45 return std::dynamic_pointer_cast<JsonArray>(data) != 0;
50 return std::dynamic_pointer_cast<JsonObject>(data) != 0;
55 return std::dynamic_pointer_cast<JsonValue>(data) != 0;
60 JsonValuePtr val = std::dynamic_pointer_cast<JsonValue>(data);
66 JsonValuePtr val = std::dynamic_pointer_cast<JsonValue>(data);
72 JsonValuePtr val = std::dynamic_pointer_cast<JsonValue>(data);
78 JsonValuePtr val = std::dynamic_pointer_cast<JsonValue>(data);
84 JsonValuePtr val = std::dynamic_pointer_cast<JsonValue>(data);
97 throw LocalException(
"JPathNavigator is not valid.");
105 std::vector<JPathNavigator> result;
106 select(parts, 0, result, limitToOne);
112 std::vector<JPathNavigator> result =
select(expr,
true);
116 void JPathNavigator::select(
const std::vector<std::string>& parts,
size_t partIndex, std::vector<JPathNavigator>& result,
bool limitToOne)
const
118 if (partIndex >= parts.size())
123 std::string
part = parts.at(partIndex);
127 for (
size_t i = 0; i <
a->elements.size(); i++)
129 JPathNavigator(
a->elements.at(i), i,
"").select(parts, partIndex + 1, result);
130 if (limitToOne && result.size() > 0)
139 for (
const std::pair<std::string, JsonDataPtr>& pair : o->elements)
141 JPathNavigator(pair.second, -1, pair.first).select(parts, partIndex + 1, result);
142 if (limitToOne && result.size() > 0)
154 JPathNavigator(child, -1,
part).select(parts, partIndex + 1, result);
173 JsonObjectPtr o = std::dynamic_pointer_cast<JsonObject>(data);
176 throw LocalException(
"Invalid cast");
187 throw LocalException(
"Invalid cast");
198 throw LocalException(
"Invalid cast");