22 using namespace HCE::exception;
28 char JsonObjExtractor::objSeparator =
'.';
29 char JsonObjExtractor::arraySeparatorBegin =
'[';
30 char JsonObjExtractor::arraySeparatorEnd =
']';
32 JsonObjExtractor::JsonObjExtractor():localObj(nullptr), localArray(nullptr) {}
42 for(
unsigned int i = 0; i < varPath.size(); i++)
44 if(varPath[i].isInteger())
46 if(localArray.isNull())
50 arrayIndex = varPath[i].extract<
int>();
51 if(static_cast<unsigned int>(arrayIndex) >= localArray->size())
55 if(localArray->isObject(arrayIndex))
57 localObj = localArray->getObject(arrayIndex);
60 else if(localArray->isArray(arrayIndex))
62 localArray = localArray->getArray(arrayIndex);
65 else if(!localArray->get(varPath[i].extract<
int>()).isEmpty())
67 localVar = localArray->get(varPath[i].extract<int>());
76 else if(varPath[i].isString())
82 if(localObj->isObject(varPath[i].extract<std::string>()))
84 localObj = localObj->getObject(varPath[i].extract<std::string>());
87 else if(localObj->isArray(varPath[i].extract<std::string>()))
89 localArray = localObj->getArray(varPath[i].extract<std::string>());
92 else if(!localObj->get(varPath[i].extract<std::string>()).isEmpty())
94 localVar = localObj->get(varPath[i].extract<std::string>());
114 catch(std::exception &exp)
122 std::stringstream intString;
125 for(
unsigned int i = 0; i < varPath.size(); i++)
127 if(varPath[i].isInteger())
133 ret += arraySeparatorBegin;
134 intString.str(std::string());
136 intString << varPath[i].extract<
int>();
137 ret += intString.str();
138 ret += arraySeparatorEnd;
140 else if(varPath[i].isString())
146 ret += (varPath[i].extract<std::string>());
154 catch(std::exception &exp)
171 std::string localName;
172 std::vector<std::string> localNames;
173 obj->getNames(localNames);
174 for(
unsigned int i = 0; i < localNames.size(); i++)
177 if(!localName.empty())
181 localName += localNames[i];
182 if(obj->isObject(localNames[i]))
186 else if(obj->isArray(localNames[i]))
190 else if(!obj->isNull(localNames[i]))
192 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);
193 crcCalc.update(localName);
194 globalMap.insert(std::pair<unsigned int, Poco::Dynamic::Var>(crcCalc.checksum(), obj->get(localNames[i])));
200 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);
201 crcCalc.update(name);
202 globalMap.insert(std::pair<unsigned int, Poco::Dynamic::Var>(crcCalc.checksum(),
localVar));
211 std::string localName;
212 std::stringstream intString;
213 for(
unsigned int i = 0; i < array->size(); i++)
217 intString.str(std::string());
220 localName += intString.str();
222 if(array->isObject(i))
226 else if(array->isArray(i))
230 else if(!array->isNull(i))
232 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);
233 crcCalc.update(localName);
234 globalMap.insert(std::pair<unsigned int, Poco::Dynamic::Var>(crcCalc.checksum(), array->get(i)));
240 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);
241 crcCalc.update(name);
242 globalMap.insert(std::pair<unsigned int, Poco::Dynamic::Var>(crcCalc.checksum(),
localVar));
261 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);