29 if (metadataJsonFileName.isEmpty()) {
34 QJsonDocument jsonDoc;
37 qCWarning(CompInfoGeneralLog) <<
"Metadata json file open failed: compid:" <<
compId <<
errorString;
40 QJsonObject jsonObj = jsonDoc.object();
42 QList<JsonParsing::KeyValidateInfo> keyInfoList = {
44 { _jsonMetadataTypesKey, QJsonValue::Array,
true },
47 qCWarning(CompInfoGeneralLog) <<
"Metadata json validation failed: compid:" <<
compId <<
errorString;
53 qCWarning(CompInfoGeneralLog) <<
"Metadata json unsupported version" << version;
57 QJsonArray rgSupportedTypes = jsonObj[_jsonMetadataTypesKey].toArray();
58 for (QJsonValue typeValue : rgSupportedTypes) {
59 int metadataType = typeValue[
"type"].toInt(-1);
60 if (metadataType == -1)
63 uris.uriMetaData = typeValue[
"uri"].toString();
64 uris.crcMetaData = typeValue[
"fileCrc"].toVariant().toLongLong();
65 uris.crcMetaDataValid = typeValue.toObject().contains(
"fileCrc");
66 uris.uriMetaDataFallback = typeValue[
"uriFallback"].toString();
67 uris.crcMetaDataFallback = typeValue[
"fileCrcFallback"].toVariant().toLongLong();
68 uris.crcMetaDataFallbackValid = typeValue.toObject().contains(
"fileCrcFallback");
69 uris.uriTranslation = typeValue[
"translationUri"].toString();
70 uris.uriTranslationFallback = typeValue[
"translationUriFallback"].toString();
72 if (uris.uriMetaData.isEmpty() || !uris.crcMetaDataValid) {
75 qCDebug(CompInfoGeneralLog) <<
"Metadata missing fields: type:uri:crcValid" << metadataType <<
76 uris.uriMetaData << uris.crcMetaDataValid;
80 _supportedTypes[(COMP_METADATA_TYPE)metadataType] = uris;
81 qCDebug(CompInfoGeneralLog) <<
"Metadata type : uri : crc" << metadataType << uris.uriMetaData << uris.crcMetaData;
bool validateKeys(const QJsonObject &jsonObject, const QList< KeyValidateInfo > &keyInfo, QString &errorString)
Validates that all required keys are present and that listed keys have the expected type.
bool isJsonFile(const QByteArray &bytes, QJsonDocument &jsonDoc, QString &errorString)
Determines whether an in-memory byte buffer contains parseable JSON content.