Struct yajl_callbacks

Struct Documentation

struct yajl_callbacks

YAJL is an event driven parser. This means as json elements are parsed, you are called back to do something with the data. The functions in this table indicate the various events for which you will be called back. Each callback accepts a “context” pointer, this is a void * that is passed into the yajl_parse() function which the client code may use to pass around context.

All callbacks return an integer. If non-zero, the parse will continue. If zero, the parse will be canceled and yajl_status_client_canceled will be returned from the parse.

Attention

A note about the handling of numbers: YAJL will only convert numbers that can be represented in a double or a 64 bit (long long) int. All other numbers will be passed to the client in string form using the yajl_number() callback. Furthermore, if yajl_number() is not NULL, it will always be used to return numbers, that is yajl_integer() and yajl_double() will be ignored. If yajl_number() is NULL but one of yajl_integer() or yajl_double() are defined, parsing of a number larger than is representable in a double or 64 bit integer will result in a parse error.

Public Members

int (*yajl_null)(void *ctx)
int (*yajl_boolean)(void *ctx, int boolVal)
int (*yajl_integer)(void *ctx, long long integerVal)
int (*yajl_double)(void *ctx, double doubleVal)
int (*yajl_number)(void *ctx, const char *numberVal, size_t numberLen)

A callback which passes the string representation of the number back to the client. Will be used for all numbers when present.

int (*yajl_string)(void *ctx, const unsigned char *stringVal, size_t stringLen)

Strings are returned as pointers into the JSON text when possible. As a result they are not zero-terminated.

int (*yajl_start_map)(void *ctx)
int (*yajl_map_key)(void *ctx, const unsigned char *key, size_t stringLen)
int (*yajl_end_map)(void *ctx)
int (*yajl_start_array)(void *ctx)
int (*yajl_end_array)(void *ctx)