QJsonParseError Struct
QJsonParseError 类用于报告 JSON 解析过程中的错误。更多
Header: | #include <QJsonParseError> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
qmake: | QT += core |
- 所有成员(包括继承成员)的列表
- QJsonParseError 是JSON Support in Qt和隐式共享类的一部分。
注意:该结构中的所有函数都是可重入的。
公共类型
enum | ParseError { NoError, UnterminatedObject, MissingNameSeparator, UnterminatedArray, MissingValueSeparator, …, GarbageAtEnd } |
公共函数
QString | errorString() const |
公共变量
另请参阅 Qt 中的 JSON 支持以及保存和加载游戏。
成员类型文档
enum QJsonParseError::ParseError
该枚举描述了在解析 JSON 文档时发生的错误类型。
常量 | 值 | 说明 |
---|---|---|
QJsonParseError::NoError | 0 | 未发生错误 |
QJsonParseError::UnterminatedObject | 1 | 对象未正确使用结尾大括号结束 |
QJsonParseError::MissingNameSeparator | 2 | 缺少分隔不同项目的逗号 |
QJsonParseError::UnterminatedArray | 3 | 数组未正确使用结尾方括号结束 |
QJsonParseError::MissingValueSeparator | 4 | 缺少分隔对象内键与值的冒号 |
QJsonParseError::IllegalValue | 5 | 值不合法 |
QJsonParseError::TerminationByNumber | 6 | 在解析数字时输入流结束(从 6.9 版起,不再返回该值) |
QJsonParseError::IllegalNumber | 7 | 数字不完整 |
QJsonParseError::IllegalEscapeSequence | 8 | 输入中出现非法转义序列 |
QJsonParseError::IllegalUTF8String | 9 | 输入中出现非法 UTF8 序列 |
QJsonParseError::UnterminatedString | 10 | 字符串未以引号结束 |
QJsonParseError::MissingObject | 11 | 预期会出现一个对象,但无法找到 |
QJsonParseError::DeepNesting | 12 | JSON 文档嵌套太深,解析器无法解析 |
QJsonParseError::DocumentTooLarge | 13 | JSON 文档太大,解析器无法解析 |
QJsonParseError::GarbageAtEnd | 14 | 解析后的文档末尾包含额外的垃圾字符 |
成员变量文档
QJsonParseError::ParseError QJsonParseError::error
包含解析错误的类型。如果文档解析正确,则等于QJsonParseError::NoError 。
另请参阅 ParseError 和errorString()。
int QJsonParseError::offset
包含发生解析错误的 UTF-8 字节数组中的字节偏移。
另请参阅 error,errorString() 和QJsonDocument::fromJson()。
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.