QJsonParseError Struct
QJsonParseError 类用于报告 JSON 解析过程中的错误。更多内容...
| 标题: | #include <QJsonParseError> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Core) target_link_libraries(mytarget PRIVATE Qt6::Core) |
| qmake: | QT += core |
- 所有成员的列表,包括继承的成员
- QJsonParseError 是Qt 中 JSON 支持以及隐式共享类的一部分。
注意:该结构体中的所有函数均为可重入的。
公共类型
| 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 | 输入中出现非法的 UTF-8 序列 |
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()。
std::conditional_t<6 < 7, int, qint64> QJsonParseError::offset
包含 UTF-8 字节数组中发生解析错误的位置的字节偏移量。
另请参阅 error 、errorString() 以及QJsonDocument::fromJson()。
© 2026 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.