File src/yajl.c


Included Files


Global Function yajl_alloc()

allocate a parser handle

yajl_handle yajl_alloc ( const yajl_callbacks* callbacks, yajl_alloc_funcs* afs, void* ctx )
\param callbacks a yajl callbacks structure specifying the functions to call when different JSON entities are encountered in the input text. May be NULL, which is only useful for validation.
\param afs memory allocation functions, may be NULL for to use C runtime library routines (malloc and friends)
\param ctx a context pointer that will be passed to callbacks.

Prototyped in: src/yajl/yajl_parse.h
Calls: yajl_buf_alloc() src/yajl_buf.c
  yajl_set_default_alloc_funcs() src/yajl_alloc.c
Called by: main() reformatter/json_reformat.c
  yajl_tree_parse() src/yajl_tree.c

Global Function yajl_complete_parse()

Parse any remaining buffered json.

yajl_status yajl_complete_parse ( yajl_handle hand )
Since yajl is a stream-based parser, without an explicit end of input, yajl sometimes can't decide if content at the end of the stream is valid or not. For example, if "1" has been fed in, yajl can't know whether another digit is next or some character that would terminate the integer token.
\param hand - a handle to the json parser allocated with yajl_alloc

Prototyped in: src/yajl/yajl_parse.h
Calls: yajl_do_finish() src/yajl_parser.c
  yajl_lex_alloc() src/yajl_lex.c
Called by: main() reformatter/json_reformat.c
  yajl_tree_parse() src/yajl_tree.c

Global Function yajl_config()

allow the modification of parser options subsequent to handle allocation (via yajl_alloc)

int yajl_config ( yajl_handle h, yajl_option opt, ... )
\returns zero in case of errors, non-zero otherwise

Prototyped in: src/yajl/yajl_parse.h
Calls: __builtin_va_arg(), __builtin_va_end(), __builtin_va_start()
Called by: main() reformatter/json_reformat.c
  yajl_tree_parse() src/yajl_tree.c

Global Function yajl_free()

free a parser handle

void yajl_free ( yajl_handle handle )

Prototyped in: src/yajl/yajl_parse.h
Calls: yajl_buf_free() src/yajl_buf.c
  yajl_lex_free() src/yajl_lex.c
Called by: main() reformatter/json_reformat.c
  yajl_tree_parse() src/yajl_tree.c

Global Function yajl_free_error()

free an error returned from yajl_get_error

void yajl_free_error ( yajl_handle hand, unsigned char* str )

Prototyped in: src/yajl/yajl_parse.h
Called by: main() reformatter/json_reformat.c

Global Function yajl_get_bytes_consumed()

get the amount of data consumed from the last chunk passed to YAJL.

size_t yajl_get_bytes_consumed ( yajl_handle hand )
In the case of a successful parse this can help you understand if the entire buffer was consumed (which will allow you to handle "junk at end of input").
In the event an error is encountered during parsing, this function affords the client a way to get the offset into the most recent chunk where the error occurred. 0 will be returned if no error was encountered.

Prototyped in: src/yajl/yajl_parse.h

Global Function yajl_get_error()

get an error string describing the state of the parse.

unsigned char* yajl_get_error ( yajl_handle hand, int verbose, const unsigned char* jsonText, size_t jsonTextLen )
If verbose is non-zero, the message will include the JSON text where the error occurred, along with an arrow pointing to the specific char.
\returns A dynamically allocated string will be returned which should be freed with yajl_free_error

Prototyped in: src/yajl/yajl_parse.h
Calls: yajl_render_error_string() src/yajl_parser.c
Called by: main() reformatter/json_reformat.c
  yajl_tree_parse() src/yajl_tree.c

Global Function yajl_parse()

Parse some json!

yajl_status yajl_parse ( yajl_handle hand, const unsigned char* jsonText, size_t jsonTextLen )
\param hand - a handle to the json parser allocated with yajl_alloc
\param jsonText - a pointer to the UTF8 json text to be parsed
\param jsonTextLength - the length, in bytes, of input text

Prototyped in: src/yajl/yajl_parse.h
Calls: yajl_do_parse() src/yajl_parser.c
  yajl_lex_alloc() src/yajl_lex.c
Called by: main() reformatter/json_reformat.c
  yajl_tree_parse() src/yajl_tree.c

Global Function yajl_status_to_string()

const char* yajl_status_to_string ( yajl_status stat )
Prototyped in: src/yajl/yajl_parse.h