-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJSON.h
More file actions
36 lines (34 loc) · 1.22 KB
/
JSON.h
File metadata and controls
36 lines (34 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#pragma once
#include "Object.h"
class JSON {
private:
SharedObject obj;
public:
static void Init();
SharedObject& content();
JSON();
explicit JSON(SharedObject obj);
JSON(std::string_view cotent);
std::string ToString();
void AddItem(JSON item);
void AddItem(std::string key, JSON item);
void Foreach(std::function<void(std::string_view key, JSON& item)> call);
void Foreach(std::function<void(int idx, JSON& item)> call);
void RemoveItem(int pos);
void RemoveItem(std::string key);
static JSON Parse(std::string_view content);
static JSON ToJson(SharedObject obj);
static JSON NewMap();
static JSON NewVec();
friend std::istream& operator >> (std::istream& in, JSON& obj);
friend std::ostream& operator << (std::ostream& out, const JSON& obj);
int VecSize();
int MapSize();
bool HasKey(const std::string& idx);
bool HasKey(int idx);
JSON& operator[] (std::string_view idx);
JSON& operator[] (int idx);
JSON& operator = (int value);
JSON& operator = (std::string_view value);
JSON& operator = (const JSON& other);
};