QJsonParseError Struct
The QJsonParseError struct is used to report errors during JSON parsing. More…
| Header | #include <QJsonParseError> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Types
| enum | ParseError |
Public Functions
| QString | errorString() const |
Public Variables
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.
| Constant | Description |
|---|---|
QJsonParseError::NoError | No error occurred |
QJsonParseError::UnterminatedObject | An object is not correctly terminated with a closing curly bracket |
QJsonParseError::MissingNameSeparator | A colon separating a name from its value is missing in an object |
QJsonParseError::UnterminatedArray | An array is not correctly terminated with a closing square bracket |
QJsonParseError::MissingValueSeparator | A comma separating different items is missing in an array or object |
QJsonParseError::IllegalValue | The value is illegal |
QJsonParseError::TerminationByNumber | The input stream ended while parsing a number |
QJsonParseError::IllegalNumber | The number is not well formed |
QJsonParseError::IllegalEscapeSequence | An illegal escape sequence occurred in the input |
QJsonParseError::IllegalUTF8String | An illegal UTF-8 sequence occurred in the input |
QJsonParseError::UnterminatedString | A string wasn't terminated with a quote |
QJsonParseError::MissingObject | An object was expected but couldn't be found |
QJsonParseError::DeepNesting | The JSON document is too deeply nested for the parser to parse it |
QJsonParseError::DocumentTooLarge | The JSON document is too large for the parser to parse it |
QJsonParseError::GarbageAtEnd | The 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.