6.0.0-rc4Source

QJsonParseError Struct

The QJsonParseError struct is used to report errors during JSON parsing. More…

Header#include <QJsonParseError>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes

List of all members, including inherited members

Public Types

Public Functions

Public Variables

intoffset
ParseErrorerror

Detailed Description

QJsonDocument::fromJson() fills one in when it is given a pointer to it. error is NoError on success; otherwise offset is the byte offset in the input at which the parser noticed the problem.

QJsonParseError err;
QJsonDocument doc = QJsonDocument::fromJson(text, &err);
if (err.error != QJsonParseError::NoError)
    qWarning() << err.errorString() << "at" << err.offset;

See also QJsonDocument::fromJson().

Differences from Qt

The members start out as 0 and NoError instead of being uninitialized. The text of errorString() is not translated.

Member Type Documentation

enum QJsonParseError::ParseError

The kinds of error the parser reports.

ConstantDescription
QJsonParseError::NoErrorNo error occurred
QJsonParseError::UnterminatedObjectAn object is not correctly terminated with a closing curly bracket
QJsonParseError::MissingNameSeparatorA colon separating a name from its value is missing in an object
QJsonParseError::UnterminatedArrayAn array is not correctly terminated with a closing square bracket
QJsonParseError::MissingValueSeparatorA comma separating different items is missing in an array or object
QJsonParseError::IllegalValueThe value is illegal
QJsonParseError::TerminationByNumberThe input stream ended while parsing a number
QJsonParseError::IllegalNumberThe number is not well formed
QJsonParseError::IllegalEscapeSequenceAn illegal escape sequence occurred in the input
QJsonParseError::IllegalUTF8StringAn illegal UTF-8 sequence occurred in the input
QJsonParseError::UnterminatedStringA string wasn't terminated with a quote
QJsonParseError::MissingObjectAn object was expected but couldn't be found
QJsonParseError::DeepNestingThe JSON document is too deeply nested for the parser to parse it
QJsonParseError::DocumentTooLargeThe JSON document is too large for the parser to parse it
QJsonParseError::GarbageAtEndThe parsed document contains additional garbage characters at the end

Member Function Documentation

QString QJsonParseError::errorString() const

Returns a text description of error.

Member Variable Documentation

ParseError QJsonParseError::error

The type of the error, or NoError.

int QJsonParseError::offset

The byte offset in the input at which the error was detected, or 0 if there was no error.