add json printing and parsing (of strings)
This commit is contained in:
parent
563b1b0c5a
commit
a13c6ecb3a
6 changed files with 277 additions and 81 deletions
21
json.h
Normal file
21
json.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef JSON_HEADER
|
||||
#define JSON_HEADER
|
||||
#include "sortedmap.h"
|
||||
#include "arraylist.h"
|
||||
enum jsontype { BOOLEAN, STRING, NUMBER, LIST, MAP };
|
||||
|
||||
typedef struct json {
|
||||
enum jsontype type;
|
||||
union {
|
||||
int boolean;
|
||||
char * string;
|
||||
double number;
|
||||
ArrayList * list;
|
||||
SortedMap * map;
|
||||
} value;
|
||||
} Json;
|
||||
|
||||
Json * json_parse(FILE *stream);
|
||||
void json_print(Json *this, FILE *stream);
|
||||
void json_free(Json *this);
|
||||
#endif
|
Loading…
Add table
Add a link
Reference in a new issue