2022-07-23 00:19:12 +00:00
|
|
|
#ifndef TELODENDRIA_JSON_H
|
|
|
|
#define TELODENDRIA_JSON_H
|
|
|
|
|
|
|
|
#include <HashMap.h>
|
|
|
|
#include <Array.h>
|
|
|
|
|
2022-07-26 01:31:09 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stddef.h>
|
|
|
|
|
2022-07-25 19:25:06 +00:00
|
|
|
typedef enum JsonType
|
|
|
|
{
|
2022-07-23 00:19:12 +00:00
|
|
|
JSON_OBJECT,
|
|
|
|
JSON_ARRAY,
|
|
|
|
JSON_STRING,
|
|
|
|
JSON_INTEGER,
|
|
|
|
JSON_FLOAT,
|
|
|
|
JSON_BOOLEAN,
|
|
|
|
JSON_NULL
|
|
|
|
} JsonType;
|
|
|
|
|
2022-07-26 01:31:09 +00:00
|
|
|
typedef struct JsonValue JsonValue;
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern JsonType
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueType(JsonValue * value);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern JsonValue *
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueObject(HashMap * object);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern HashMap *
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueAsObject(JsonValue * value);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern JsonValue *
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueArray(Array * array);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern Array *
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueAsArray(JsonValue * value);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern JsonValue *
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueString(char *string);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern JsonValue *
|
2022-07-27 13:47:22 +00:00
|
|
|
JsonValueInteger(long integer);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern JsonValue *
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueFloat(double floating);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern JsonValue *
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueBoolean(int boolean);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern JsonValue *
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueNull(void);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
2022-07-26 01:31:09 +00:00
|
|
|
extern void
|
2022-07-25 19:25:06 +00:00
|
|
|
JsonValueFree(JsonValue * value);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
2022-07-26 01:31:09 +00:00
|
|
|
extern void
|
|
|
|
JsonFree(HashMap * object);
|
|
|
|
|
2022-07-27 21:27:34 +00:00
|
|
|
extern void
|
|
|
|
JsonEncodeString(const char *str, FILE * out);
|
|
|
|
|
|
|
|
extern void
|
|
|
|
JsonEncodeValue(JsonValue * value, FILE * out);
|
|
|
|
|
2022-07-25 20:26:30 +00:00
|
|
|
extern int
|
|
|
|
JsonEncode(HashMap * object, FILE * out);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
extern HashMap *
|
2022-07-25 20:26:30 +00:00
|
|
|
JsonDecode(FILE * in);
|
2022-07-23 00:19:12 +00:00
|
|
|
|
|
|
|
#endif
|