43 lines
1.3 KiB
C++
43 lines
1.3 KiB
C++
#pragma once
|
||
#include "pub.h"
|
||
|
||
class Json
|
||
{
|
||
private:
|
||
int type = 0;//1是对象,2是数组,3是字符串,4是数字或布尔或null
|
||
std::map<CString, Json> valueMap; //存放json对象
|
||
std::map<CString, Json>::iterator CurrIter;
|
||
std::vector<Json> valueVector; //存放数组对象
|
||
CString value = _T(""); //值
|
||
int insertObj(const CString JsonStr, Json& json); //解析对象
|
||
int insertArr(const CString JsonStr, Json& json); //解析数组
|
||
int insertNum(CString str, Json& json); //解析数字
|
||
int GetValue(CString jsonStr, int Begin, CString& value);
|
||
public:
|
||
~Json();
|
||
int parse(CStringA str); //解析数据
|
||
int parse(CStringW JsonStr); //解析数据
|
||
Json& operator[] (int JsonInt);
|
||
Json& operator[] (CStringW JsonStr);
|
||
Json& operator[] (CStringA JsonStr);
|
||
void operator= (int Json);
|
||
void operator= (CStringA JsonStr);
|
||
void operator= (CStringW JsonStr);
|
||
void operator= (Json JsonInt);
|
||
void append(Json Json);
|
||
void clear();
|
||
void RemoveAt(CStringA Item);
|
||
void RemoveAt(CString Item);
|
||
void RemoveAt(INT Index);
|
||
CStringA asCStringA();
|
||
CString asCString();
|
||
int asInt();
|
||
double asDouble();
|
||
UINT Size(); //获取数组或者MAP的个数
|
||
std::map<CString, Json>::iterator getBegin();
|
||
std::map<CString, Json>::iterator getEnd();
|
||
std::map<CString, Json>::iterator Find(CString key);
|
||
CStringW writeCString(); //把json对象转换成CString
|
||
CStringA write(); //把json对象转换成String
|
||
};
|