QJsonDocument


QJsonDocument 

QJsonDocument类提供了一种读取和写入JSON文档的方法。

QJsonDocument是一个封装完整JSON文档的类,可以从UTF-8编码的基于文本的表示以及Qt自己的二进制格式读取和写入此文档。

可以使用QJsonDocument::fromJson()将JSON文档从基于文本的表示转换为QJsonDocument。toJson()将其转换回文本。解析器非常快速高效,可以将JSON转换为Qt使用的二进制表示形式。

已解析文档的有效性可以使用!isNull()

可以使用isArray()和isObject()查询文档,确定它是包含数组还是对象。可以使用array()或object()检索文档中包含的数组或对象,然后进行读取或操作。

还可以使用fromBinaryData()或fromRawData()从存储的二进制表示形式创建文档。

 

头文件

#include <QJsonDocument>

 

 

 

QJsonDocument()
  QJsonDocument(const QJsonObject &object)
  QJsonDocument(const QJsonArray &array)
  QJsonDocument(const QJsonDocument &other)
  QJsonDocument(QJsonDocument &&other)
  ~QJsonDocument()
QJsonArray array() const
bool isArray() const
bool isEmpty() const
bool isNull() const
bool isObject() const
QJsonObject object() const
const char * rawData(int *size) const
void setArray(const QJsonArray &array)
void setObject(const QJsonObject &object)
void swap(QJsonDocument &other)
QByteArray toBinaryData() const
QByteArray toJson() const
QByteArray toJson(QJsonDocument::JsonFormat format) const
QVariant toVariant() const
bool operator!=(const QJsonDocument &other) const
QJsonDocument & operator=(const QJsonDocument &other)
QJsonDocument & operator=(QJsonDocument &&other)
bool operator==(const QJsonDocument &other) const
const QJsonValue operator[](const QString &key) const
const QJsonValue operator[](QLatin1String key) const
const QJsonValue operator[](int i) const

 

 

 

 

 

 

#################################


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM