jx_parse.h File Reference
Parse JSON strings and files into JX expressions.
More...
#include "jx.h"
#include "link.h"
#include <stdio.h>
Go to the source code of this file.
Detailed Description
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:
-
Atomic values are limited to 4KB in size.
-
Bare identifiers are permitted, to enable expression evaluation.
Function Documentation
struct jx* jx_parse_string |
( |
const char * |
str |
) |
[read] |
Parse a JSON string to a JX expression.
- Parameters:
-
| str | A C string containing JSON data. |
- Returns:
- A JX expression which must be deleted with jx_delete. If the parse fails or no JSON value is present, null is returned.
struct jx* jx_parse_stream |
( |
FILE * |
file |
) |
[read] |
Parse a standard IO stream to a JX expression.
- Parameters:
-
| file | A stream containing JSON data. |
- Returns:
- A JX expression which must be deleted with jx_delete. If the parse fails or no JSON value is present, null is returned.
struct jx* jx_parse_file |
( |
const char * |
name |
) |
[read] |
Parse a file to a JX expression.
- Parameters:
-
| name | The name of a file containing JSON data. |
- Returns:
- A JX expression which must be deleted with jx_delete. If the parse fails or no JSON value is present, null is returned.
struct jx* jx_parse_link |
( |
struct link * |
l, |
|
|
time_t |
stoptime | |
|
) |
| | [read] |
Parse a network link to a JX expression.
- Parameters:
-
| l | A link object. |
| stoptime | The absolute time at which to stop. |
- Returns:
- A JX expression which must be deleted with jx_delete. If the parse fails or no JSON value is present, null is returned.
struct jx_parser* jx_parser_create |
( |
|
) |
[read] |
Create a JX parser object.
- Returns:
- A parser object.
void jx_parser_read_stream |
( |
struct jx_parser * |
p, |
|
|
FILE * |
file | |
|
) |
| | |
Attach parser to a file.
- Parameters:
-
| 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.
- Parameters:
-
| 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.
- Parameters:
-
| p | A parser object. |
| l | A link object. |
| stoptime | The absolute time at which to stop. |
struct jx* jx_parse |
( |
struct jx_parser * |
p |
) |
[read] |
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.
- Parameters:
-
- Returns:
- A JX expression, or null if nothing was parsed.
int jx_parser_errors |
( |
struct jx_parser * |
p |
) |
|
Return number of parse errors.
- Parameters:
-
- Returns:
- Number of parse errors encountered.
const char* jx_parser_error_string |
( |
struct jx_parser * |
p |
) |
|
Return text of parse error.
- Parameters:
-
- Returns:
- Error string, if available, null otherwise.
void jx_parser_delete |
( |
struct jx_parser * |
p |
) |
|
Delete a parser.
- Parameters:
-