cctools
|
Parse JSON strings and files into JX expressions. More...
Go to the source code of this file.
Functions | |
struct jx * | jx_parse_string (const char *str) |
Parse a JSON string to a JX expression. More... | |
struct jx * | jx_parse_stream (FILE *file) |
Parse a standard IO stream to a JX expression. More... | |
struct jx * | jx_parse_file (const char *name) |
Parse a file to a JX expression. More... | |
struct jx * | jx_parse_link (struct link *l, time_t stoptime) |
Parse a network link to a JX expression. More... | |
struct jx * | jx_parse_cmd_args (struct jx *jx_args, char *args_file) |
Parse a jx argument file from a commandline option. More... | |
int | jx_parse_cmd_define (struct jx *jx_args, char *define_stmt) |
Parse a jx define statement from a commandline option. More... | |
struct jx_parser * | jx_parser_create (bool strict_mode) |
Create a JX parser object. More... | |
void | jx_parser_read_stream (struct jx_parser *p, FILE *file) |
Attach parser to a file. More... | |
void | jx_parser_read_string (struct jx_parser *p, const char *str) |
Attach parser to a string. More... | |
void | jx_parser_read_link (struct jx_parser *p, struct link *l, time_t stoptime) |
Attach parser to a link. More... | |
struct jx * | jx_parser_yield (struct jx_parser *p) |
Parse and return a single value. More... | |
struct jx * | jx_parse (struct jx_parser *p) |
Parse a JX expression. More... | |
int | jx_parser_errors (struct jx_parser *p) |
Return number of parse errors. More... | |
const char * | jx_parser_error_string (struct jx_parser *p) |
Return text of first parse error encountered. More... | |
void | jx_parser_delete (struct jx_parser *p) |
Delete a parser. More... | |
Parse JSON strings and files into JX expressions.
This module parses arbirary JSON expressions according to the definition at json.org, with the following exceptions:
struct jx* jx_parse_string | ( | const char * | str | ) |
Parse a JSON string to a JX expression.
str | A C string containing JSON data. |
struct jx* jx_parse_stream | ( | FILE * | file | ) |
Parse a standard IO stream to a JX expression.
file | A stream containing JSON data. |
struct jx* jx_parse_file | ( | const char * | name | ) |
Parse a file to a JX expression.
name | The name of a file containing JSON data. |
struct jx* jx_parse_link | ( | struct link * | l, |
time_t | stoptime | ||
) |
Parse a network link to a JX expression.
l | A link pointer (opaque struct). |
stoptime | The absolute time at which to stop. |
Parse a jx argument file from a commandline option.
The passed-in object is consumed.
jx_args | A JX object to add args to. |
args_file | Name of the jx_args file that will be read in. |
int jx_parse_cmd_define | ( | struct jx * | jx_args, |
char * | define_stmt | ||
) |
Parse a jx define statement from a commandline option.
jx_args | A JX object to add args to. |
define_stmt | Command line value of from VAR=EXPR. |
struct jx_parser* jx_parser_create | ( | bool | strict_mode | ) |
Create a JX parser object.
void jx_parser_read_stream | ( | struct jx_parser * | p, |
FILE * | file | ||
) |
Attach parser to a file.
p | A parser object. |
file | A standard IO stream. |
void jx_parser_read_string | ( | struct jx_parser * | p, |
const char * | str | ||
) |
Attach parser to a string.
p | A parser object. |
str | A JSON string to parse. |
void jx_parser_read_link | ( | struct jx_parser * | p, |
struct link * | l, | ||
time_t | stoptime | ||
) |
Attach parser to a link.
p | A parser object. |
l | A link object. |
stoptime | The absolute time at which to stop. |
struct jx* jx_parser_yield | ( | struct jx_parser * | p | ) |
Parse and return a single value.
This function is useful for streaming multiple independent values from a single source.
p | A parser object |
struct jx* jx_parse | ( | struct jx_parser * | p | ) |
Parse a JX expression.
Note that in the event of a parse error, this function can return a partial result, reflecting the text that was parseable. You must call jx_parser_errors to determine if the parse was successul.
p | A parser created by jx_parser_create. |
int jx_parser_errors | ( | struct jx_parser * | p | ) |
Return number of parse errors.
p | A parser object. |
const char* jx_parser_error_string | ( | struct jx_parser * | p | ) |
Return text of first parse error encountered.
p | A parser object. |
void jx_parser_delete | ( | struct jx_parser * | p | ) |
Delete a parser.
p | The parser to delete. |