-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjson.h
More file actions
31 lines (24 loc) · 712 Bytes
/
json.h
File metadata and controls
31 lines (24 loc) · 712 Bytes
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
#ifndef __JSON_H__
#define __JSON_H__
#include <stdbool.h>
typedef struct {
enum { ELEMENT_INT, ELEMENT_STRING, ELEMENT_LIST } type;
union {
int as_int;
char* as_string;
struct _Node* as_list;
}; // ANONYMOUS union (C11).
} Element;
typedef struct _Node {
struct _Node* next;
Element element;
} Node;
bool parse_int(int* a_value, char const** a_pos);
bool parse_string(char** a_s, char const** a_pos);
bool parse_element(Element* a_element, char const** a_pos);
bool parse_list(Node** a_head, char const** a_pos);
void print_element(Element element);
void free_element(Element element);
#endif
#define JSON_H_VERSION_2
/* vim: set tabstop=4 shiftwidth=4 fileencoding=utf-8 noexpandtab: */