-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson.h
79 lines (64 loc) · 1.26 KB
/
json.h
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* json.h
*
* Created on: 23 Mar 2016
* Author: clast
*/
#ifndef JSON_H_
#define JSON_H_
#define JSON_KEYS_MAX 10000
#define JSON_LABEL_LENGTH_MAX 256
enum JsonValueType;
enum JsonReturnType;
union JsonValue;
struct JsonArray;
struct JsonObject;
typedef enum JsonValueType
{
JSON_ARRAY=1,
JSON_OBJECT,
JSON_STRING,
JSON_INTEGER,
JSON_REAL,
JSON_BOOLEAN,
JSON_NULL
} JsonValueType;
typedef union JsonValue
{
struct JsonArray* pArray;
struct JsonObject* pObject;
char* string;
long integer;
double real;
int boolean;
} JsonValue;
// A value is a single object, array or data item
typedef struct JsonKey
{
char* key;
enum JsonValueType valuetype;
union JsonValue value;
} JsonKey;
// An object is a list of key value pairs
typedef struct JsonObject
{
struct JsonKey* this;
struct JsonObject* next;
} JsonObject;
// An array is a list of objects
typedef struct JsonArray
{
struct JsonObject* this;
struct JsonArray* next;
} JsonArray;
typedef enum JsonReturnType
{
JSON_OK=0,
JSON_EMPTY,
JSON_ERROR
} JsonReturnType;
JsonKey* JsonGet(char* key);
JsonReturnType JsonLoad(const char* string);
int JsonKeys;
char *JsonKeyList[JSON_KEYS_MAX];
#endif /* JSON_H_ */