Add Paths entry parsing to json parser

This commit is contained in:
Simon Walton 2018-11-13 17:58:12 -08:00
parent 82e21e89e4
commit 452c212c4f

View file

@ -117,6 +117,28 @@ bool OctreeEntitiesFileParser::parseEntities(QVariantMap& parsedEntities) {
int versionValue = readInteger();
parsedEntities["Version"] = versionValue;
gotVersion = true;
} else if (key == "Paths") {
// Serverless JSON has optional Paths entry.
if (nextToken() != '{') {
_errorString = "Paths item is not an object";
return false;
}
int matchingBrace = findMatchingBrace();
if (matchingBrace < 0) {
_errorString = "Unterminated entity object";
return false;
}
QByteArray jsonObject = _entitiesContents.mid(_position - 1, matchingBrace - _position + 1);
QJsonDocument pathsObject = QJsonDocument::fromJson(jsonObject);
if (pathsObject.isNull()) {
_errorString = "Ill-formed paths entry";
return false;
}
parsedEntities["Paths"] = pathsObject.object();
_position = matchingBrace;
} else {
_errorString = "Unrecognized key name: " + key;
return false;