QGroundControl
Ground Control Station for MAVLink Drones
Loading...
Searching...
No Matches
JsonParsing Namespace Reference

Functions

bool validateRequiredKeys (const QJsonObject &jsonObject, const QStringList &keys, QString &errorString)
 Validates that all listed keys are present in the object.
 
bool validateKeyTypes (const QJsonObject &jsonObject, const QStringList &keys, const QList< QJsonValue::Type > &types, QString &errorString)
 
bool isJsonFile (const QByteArray &bytes, QJsonDocument &jsonDoc, QString &errorString)
 Determines whether an in-memory byte buffer contains parseable JSON content.
 
bool isJsonFile (const QString &fileName, QJsonDocument &jsonDoc, QString &errorString)
 Determines whether a file path contains parseable JSON content.
 
double possibleNaNJsonValue (const QJsonValue &value)
 Returns NaN if the value is null, or the value converted to double otherwise.
 

Function Documentation

◆ isJsonFile() [1/2]

bool JsonParsing::isJsonFile ( const QByteArray &  bytes,
QJsonDocument &  jsonDoc,
QString &  errorString 
)

◆ isJsonFile() [2/2]

bool JsonParsing::isJsonFile ( const QString &  fileName,
QJsonDocument &  jsonDoc,
QString &  errorString 
)

Determines whether a file path contains parseable JSON content.

Definition at line 110 of file JsonParsing.cc.

References errorString, isJsonFile(), and QGCFileHelper::readFile().

◆ possibleNaNJsonValue()

double JsonParsing::possibleNaNJsonValue ( const QJsonValue &  value)

Returns NaN if the value is null, or the value converted to double otherwise.

Definition at line 120 of file JsonParsing.cc.

Referenced by MissionItem::load(), SimpleMissionItem::load(), JsonHelper::loadGeoCoordinate(), and MissionCommandUIInfo::loadJsonInfo().

◆ validateKeyTypes()

bool JsonParsing::validateKeyTypes ( const QJsonObject &  jsonObject,
const QStringList &  keys,
const QList< QJsonValue::Type > &  types,
QString &  errorString 
)

Validates value types for listed keys that are present in the object. QJsonValue::Null as expected type means "double value with possible NaN".

Definition at line 64 of file JsonParsing.cc.

References errorString.

Referenced by MissionCommandUIInfo::loadJsonInfo().

◆ validateRequiredKeys()

bool JsonParsing::validateRequiredKeys ( const QJsonObject &  jsonObject,
const QStringList &  keys,
QString &  errorString 
)

Validates that all listed keys are present in the object.

Definition at line 43 of file JsonParsing.cc.

References errorString.

Referenced by QGCMapPolygon::loadFromJson(), QGCMapPolyline::loadFromJson(), and MissionCommandUIInfo::loadJsonInfo().