Initial commit

This commit is contained in:
ktkk 2025-04-02 12:52:45 +00:00
commit d2182a433c
9 changed files with 421 additions and 0 deletions

45
json.h Normal file
View file

@ -0,0 +1,45 @@
#ifndef JSON_H
#define JSON_H
#include <stdio.h>
typedef enum Whitespace {
MINIFIED,
INDENT_1,
INDENT_2,
INDENT_3,
INDENT_4,
INDENT_8,
INDENT_TAB,
} Whitespace;
typedef enum Punctuation {
BEGINNING,
NONE,
COMMA,
COLON,
} Punctuation;
typedef struct Json {
FILE* stream;
Whitespace whitespace;
int indent_level;
Punctuation next_punctuation;
} Json;
Json json_init(FILE* stream, Whitespace whitespace);
void json_free(Json* json);
void json_begin_array(Json* json);
void json_end_array(Json* json);
void json_begin_object(Json* json);
void json_end_object(Json* json);
void json_add_object_field(Json* json, const char* key);
void json_add_string(Json* json, const char* value);
void json_add_long(Json* json, long value);
void json_add_double(Json* json, double value);
void json_add_bool(Json* json, bool value);
void json_add_null(Json* json);
#endif // JSON_H