MCPcopy Create free account
hub / github.com/baldurk/renderdoc / validateForJSON

Function validateForJSON

qrenderdoc/Code/QRDUtils.cpp:2243–2272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2241}
2242
2243static void validateForJSON(const QVariant &data, QString path = QString())
2244{
2245 switch((QMetaType::Type)data.type())
2246 {
2247 case QMetaType::QVariantList:
2248 {
2249 QVariantList list = data.toList();
2250 int i = 0;
2251 for(QVariant &v : list)
2252 validateForJSON(v, path + QFormatStr("[%1]").arg(i++));
2253 break;
2254 }
2255 case QMetaType::QVariantMap:
2256 {
2257 QVariantMap map = data.toMap();
2258 for(const QString &str : map.keys())
2259 validateForJSON(map[str], path + lit(".") + str);
2260 break;
2261 }
2262 case QMetaType::QByteArray:
2263 {
2264 qCritical() << "Qt can't reliably serialise QByteArray to JSON.\n"
2265 << "Older versions write it as a byte string, new versions base64 encode it.\n"
2266 << "Manually encode if needed and add value as string." << path;
2267 }
2268 default:
2269 // all other types we assume are fine
2270 break;
2271 }
2272}
2273
2274static QJsonDocument validateAndMakeJSON(const QVariantMap &data)
2275{

Callers 1

validateAndMakeJSONFunction · 0.85

Calls 5

QStringFunction · 0.50
typeMethod · 0.45
toListMethod · 0.45
argMethod · 0.45
keysMethod · 0.45

Tested by

no test coverage detected