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
{
29
UJSON_VOID
= 0,
31
UJSON_INT
,
33
UJSON_FLOAT
,
35
UJSON_BOOL
,
37
UJSON_NULL
,
39
UJSON_STR
,
41
UJSON_OBJ
,
43
UJSON_ARR
,
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 */
ujson_reader
A JSON parser internal state.
Definition:
ujson_reader.h:50
ujson_val
A parsed JSON key value pair.
Definition:
ujson_reader.h:91
ujson_writer
A JSON writer.
Definition:
ujson_writer.h:30
ujson_type_name
const char * ujson_type_name(enum ujson_type type)
Returns type name.
ujson_err_handler
void ujson_err_handler(void *print_priv, const char *line)
Default error print handler.
ujson_type
ujson_type
A JSON data type.
Definition:
ujson_common.h:27
UJSON_STR
@ UJSON_STR
A string.
Definition:
ujson_common.h:39
UJSON_FLOAT
@ UJSON_FLOAT
A floating point.
Definition:
ujson_common.h:33
UJSON_OBJ
@ UJSON_OBJ
A JSON object.
Definition:
ujson_common.h:41
UJSON_BOOL
@ UJSON_BOOL
A boolean.
Definition:
ujson_common.h:35
UJSON_NULL
@ UJSON_NULL
NULL.
Definition:
ujson_common.h:37
UJSON_INT
@ UJSON_INT
An integer.
Definition:
ujson_common.h:31
UJSON_ARR
@ UJSON_ARR
A JSON array.
Definition:
ujson_common.h:43
UJSON_VOID
@ UJSON_VOID
No type. Returned when parser finishes.
Definition:
ujson_common.h:29
Generated by
1.9.1