ujson
Complete and simple JSON reader and writer written in C
ujson_common.h
Go to the documentation of this file.
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 /*
3  * Copyright (C) 2021-2024 Cyril Hrubis <metan@ucw.cz>
4  */
5 
11 #ifndef UJSON_COMMON_H
12 #define UJSON_COMMON_H
13 
15 #define UJSON_ERR_MAX 128
17 #define UJSON_ID_MAX 64
19 #define UJSON_RECURSION_MAX 128
20 
21 #define UJSON_ERR_PRINT ujson_err_handler
22 #define UJSON_ERR_PRINT_PRIV stderr
23 
27 enum ujson_type {
44 };
45 
52 const char *ujson_type_name(enum ujson_type type);
53 
60 void ujson_err_handler(void *print_priv, const char *line);
61 
62 typedef struct ujson_reader ujson_reader;
63 typedef struct ujson_writer ujson_writer;
64 typedef struct ujson_val ujson_val;
65 
67 #define UJSON_ARRAY_SIZE(array) (sizeof(array) / sizeof(*array))
68 
69 #endif /* UJSON_COMMON_H */
A JSON parser internal state.
Definition: ujson_reader.h:50
A parsed JSON key value pair.
Definition: ujson_reader.h:91
A JSON writer.
Definition: ujson_writer.h:30
const char * ujson_type_name(enum ujson_type type)
Returns type name.
void ujson_err_handler(void *print_priv, const char *line)
Default error print handler.
ujson_type
A JSON data type.
Definition: ujson_common.h:27
@ UJSON_STR
A string.
Definition: ujson_common.h:39
@ UJSON_FLOAT
A floating point.
Definition: ujson_common.h:33
@ UJSON_OBJ
A JSON object.
Definition: ujson_common.h:41
@ UJSON_BOOL
A boolean.
Definition: ujson_common.h:35
@ UJSON_NULL
NULL.
Definition: ujson_common.h:37
@ UJSON_INT
An integer.
Definition: ujson_common.h:31
@ UJSON_ARR
A JSON array.
Definition: ujson_common.h:43
@ UJSON_VOID
No type. Returned when parser finishes.
Definition: ujson_common.h:29