47
typedef struct JSON_value_struct {
49
JSON_int_t integer_value;
51
typedef struct JSON_value_struct
55
JSON_int_t integer_value;
51
57
long double float_value;
60
/*! \brief JSON parser callback
67
/*! \brief JSON parser callback
62
69
\param ctx The pointer passed to new_JSON_parser.
63
\param type An element of JSON_type but not JSON_T_NONE.
64
\param value A representation of the parsed value. This parameter is NULL for
65
JSON_T_ARRAY_BEGIN, JSON_T_ARRAY_END, JSON_T_OBJECT_BEGIN, JSON_T_OBJECT_END,
66
JSON_T_NULL, JSON_T_TRUE, and SON_T_FALSE. String values are always returned
70
\param type An element of JSON_type but not JSON_T_NONE.
71
\param value A representation of the parsed value. This parameter is NULL
73
JSON_T_ARRAY_BEGIN, JSON_T_ARRAY_END, JSON_T_OBJECT_BEGIN,
75
JSON_T_NULL, JSON_T_TRUE, and SON_T_FALSE. String values are always
67
77
as zero-terminated C strings.
69
79
\return Non-zero if parsing should continue, else zero.
71
typedef int (*JSON_parser_callback)(void* ctx, int type, const struct JSON_value_struct* value);
74
/*! \brief The structure used to configure a JSON parser object
76
\param depth If negative, the parser can parse arbitrary levels of JSON, otherwise
81
typedef int ( *JSON_parser_callback )( void* ctx, int type,
82
const struct JSON_value_struct*
86
/*! \brief The structure used to configure a JSON parser object
88
\param depth If negative, the parser can parse arbitrary levels of JSON,
77
90
the depth is the limit
78
\param Pointer to a callback. This parameter may be NULL. In this case the input is merely checked for validity.
91
\param Pointer to a callback. This parameter may be NULL. In this case the
92
input is merely checked for validity.
79
93
\param Callback context. This parameter may be NULL.
80
\param depth. Specifies the levels of nested JSON to allow. Negative numbers yield unlimited nesting.
94
\param depth. Specifies the levels of nested JSON to allow. Negative numbers
95
yield unlimited nesting.
81
96
\param allowComments. To allow C style comments in JSON, set to non-zero.
82
\param handleFloatsManually. To decode floating point numbers manually set this parameter to non-zero.
97
\param handleFloatsManually. To decode floating point numbers manually set
98
this parameter to non-zero.
84
100
\return The parser object.
86
typedef struct JSON_config_struct {
87
JSON_parser_callback callback;
91
int handle_floats_manually;
102
typedef struct JSON_config_struct
104
JSON_parser_callback callback;
108
int handle_floats_manually;
95
/*! \brief Initializes the JSON parser configuration structure to default values.
112
/*! \brief Initializes the JSON parser configuration structure to default
97
115
The default configuration is
98
- 127 levels of nested JSON (depends on JSON_PARSER_STACK_SIZE, see json_parser.c)
116
- 127 levels of nested JSON (depends on JSON_PARSER_STACK_SIZE, see
99
118
- no parsing, just checking for JSON syntax
102
121
\param config. Used to configure the parser.
104
JSON_PARSER_DLL_API void init_JSON_config(JSON_config* config);
106
/*! \brief Create a JSON parser object
108
\param config. Used to configure the parser. Set to NULL to use the default configuration.
123
JSON_PARSER_DLL_API void init_JSON_config(
124
JSON_config* config );
126
/*! \brief Create a JSON parser object
128
\param config. Used to configure the parser. Set to NULL to use the default
109
130
See init_JSON_config
111
132
\return The parser object.
113
JSON_PARSER_DLL_API extern struct JSON_parser_struct* new_JSON_parser(JSON_config* config);
134
JSON_PARSER_DLL_API extern struct JSON_parser_struct* new_JSON_parser(
135
JSON_config* config );
115
137
/*! \brief Destroy a previously created JSON parser object. */
116
JSON_PARSER_DLL_API extern void delete_JSON_parser(struct JSON_parser_struct* jc);
138
JSON_PARSER_DLL_API extern void delete_JSON_parser(
139
struct JSON_parser_struct* jc );
118
141
/*! \brief Parse a character.
120
\return Non-zero, if all characters passed to this function are part of are valid JSON.
122
JSON_PARSER_DLL_API extern int JSON_parser_char(struct JSON_parser_struct* jc, int next_char);
143
\return Non-zero, if all characters passed to this function are part of are
146
JSON_PARSER_DLL_API extern int JSON_parser_char(
147
struct JSON_parser_struct* jc,
124
151
/*! \brief Finalize parsing.
126
153
Call this method once after all input characters have been consumed.
128
155
\return Non-zero, if all parsed characters are valid JSON, zero otherwise.
130
JSON_PARSER_DLL_API extern int JSON_parser_done(struct JSON_parser_struct* jc);
157
JSON_PARSER_DLL_API extern int JSON_parser_done(
158
struct JSON_parser_struct* jc );
132
/*! \brief Determine if a given string is valid JSON white space
160
/*! \brief Determine if a given string is valid JSON white space
134
162
\return Non-zero if the string is valid, zero otherwise.
136
JSON_PARSER_DLL_API extern int JSON_parser_is_legal_white_space_string(const char* s);
164
JSON_PARSER_DLL_API extern int
165
JSON_parser_is_legal_white_space_string(
139
169
#ifdef __cplusplus
144
174
#endif /* JSON_PARSER_H */