22 using namespace HCE::exception;
28 char JsonObjExtractor::objSeparator =
'.';
29 char JsonObjExtractor::arraySeparatorBegin =
'[';
30 char JsonObjExtractor::arraySeparatorEnd =
']';
32 JsonObjExtractor::JsonObjExtractor():localObj(nullptr), localArray(nullptr) {}
41 for(
unsigned int i = 0; i < varPath.size(); i++)
43 if(varPath[i].isInteger())
45 if(localArray.isNull())
49 arrayIndex = varPath[i].extract<
int>();
50 if(static_cast<unsigned int>(arrayIndex) >= localArray->size())
54 if(localArray->isObject(arrayIndex))
56 localObj = localArray->getObject(arrayIndex);
59 else if(localArray->isArray(arrayIndex))
61 localArray = localArray->getArray(arrayIndex);
64 else if(!localArray->get(varPath[i].extract<
int>()).isEmpty())
66 localVar = localArray->get(varPath[i].extract<int>());
75 else if(varPath[i].isString())
81 if(localObj->isObject(varPath[i].extract<std::string>()))
83 localObj = localObj->getObject(varPath[i].extract<std::string>());
86 else if(localObj->isArray(varPath[i].extract<std::string>()))
88 localArray = localObj->getArray(varPath[i].extract<std::string>());
91 else if(!localObj->get(varPath[i].extract<std::string>()).isEmpty())
93 localVar = localObj->get(varPath[i].extract<std::string>());
113 catch(std::exception &exp)
121 std::stringstream intString;
124 for(
unsigned int i = 0; i < varPath.size(); i++)
126 if(varPath[i].isInteger())
132 ret += arraySeparatorBegin;
133 intString.str(std::string());
135 intString << varPath[i].extract<
int>();
136 ret += intString.str();
137 ret += arraySeparatorEnd;
139 else if(varPath[i].isString())
145 ret += (varPath[i].extract<std::string>());
153 catch(std::exception &exp)
169 std::string localName;
170 std::vector<std::string> localNames;
171 obj->getNames(localNames);
172 for(
unsigned int i = 0; i < localNames.size(); i++)
175 if(!localName.empty())
179 localName += localNames[i];
180 if(obj->isObject(localNames[i]))
184 else if(obj->isArray(localNames[i]))
188 else if(!obj->isNull(localNames[i]))
190 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);
191 crcCalc.update(localName);
192 globalMap.insert(std::pair<unsigned int, Poco::Dynamic::Var>(crcCalc.checksum(), obj->get(localNames[i])));
198 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);
199 crcCalc.update(name);
200 globalMap.insert(std::pair<unsigned int, Poco::Dynamic::Var>(crcCalc.checksum(),
localVar));
209 std::string localName;
210 std::stringstream intString;
211 for(
unsigned int i = 0; i < array->size(); i++)
215 intString.str(std::string());
218 localName += intString.str();
220 if(array->isObject(i))
224 else if(array->isArray(i))
228 else if(!array->isNull(i))
230 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);
231 crcCalc.update(localName);
232 globalMap.insert(std::pair<unsigned int, Poco::Dynamic::Var>(crcCalc.checksum(), array->get(i)));
238 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);
239 crcCalc.update(name);
240 globalMap.insert(std::pair<unsigned int, Poco::Dynamic::Var>(crcCalc.checksum(),
localVar));
257 Poco::Checksum crcCalc(Poco::Checksum::TYPE_CRC32);