You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nmWTAI-Platform/Include/nmNum/nmData/nmDataJsonTools.h

36 lines
1.1 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#ifndef NMDATAJSONTOOLS_H
#define NMDATAJSONTOOLS_H
#include "nmData_global.h"
#include <QObject>
#include <QVector>
#include <QVariant>
#include "rapidjson/document.h"
class NM_DATA_EXPORT nmDataJsonTools : public QObject
{
Q_OBJECT
public:
// JSON写入方法
static void jsonAdd(rapidjson::Document& document, QVariant value, QVector<QVariant> path);
// JSON读取方法
static void jsonRead(rapidjson::Document& document, QVariant& value, QVector<QVariant> path);
// 将 RapidJSON Document 写入文件
// @param doc 要写入的RapidJSON Document
// @param filePath 写入文件的路径
// @return 写入成功返回 true否则返回 false
static bool WriteDomToFile(const rapidjson::Document& doc, const QString& filePath);
// 从文件读取 JSON 并解析到 RapidJSON Document
// @param filePath 读取文件的路径
// @param doc 解析后的RapidJSON Document
// @return 读取并解析成功返回 true否则返回 false
static bool ReadDomFromFile(const QString& filePath, rapidjson::Document& doc);
};
#endif // NMDATAJSONTOOLS_H