#include "json.h"
#include <glib.h>
#include <stdio.h>
Go to the source code of this file.
|
enum | gvm_json_pull_container_type_t { GVM_JSON_PULL_CONTAINER_NONE = 0
, GVM_JSON_PULL_CONTAINER_ARRAY
, GVM_JSON_PULL_CONTAINER_OBJECT
} |
| Type of container the parser is currently in. More...
|
|
enum | gvm_json_pull_event_type_t {
GVM_JSON_PULL_EVENT_UNDEFINED = 0
, GVM_JSON_PULL_EVENT_ARRAY_START
, GVM_JSON_PULL_EVENT_ARRAY_END
, GVM_JSON_PULL_EVENT_OBJECT_START
,
GVM_JSON_PULL_EVENT_OBJECT_END
, GVM_JSON_PULL_EVENT_STRING
, GVM_JSON_PULL_EVENT_NUMBER
, GVM_JSON_PULL_EVENT_BOOLEAN
,
GVM_JSON_PULL_EVENT_NULL
, GVM_JSON_PULL_EVENT_EOF
, GVM_JSON_PULL_EVENT_ERROR
} |
| Event types for the JSON pull parser. More...
|
|
enum | gvm_json_pull_expect_t {
GVM_JSON_PULL_EXPECT_UNDEFINED = 0
, GVM_JSON_PULL_EXPECT_VALUE
, GVM_JSON_PULL_EXPECT_KEY
, GVM_JSON_PULL_EXPECT_COMMA
,
GVM_JSON_PULL_EXPECT_EOF
} |
| Expected token state for the JSON pull parser. More...
|
|
◆ _GNU_SOURCE
◆ GVM_JSON_PULL_PARSE_BUFFER_LIMIT
#define GVM_JSON_PULL_PARSE_BUFFER_LIMIT 10485760 |
◆ GVM_JSON_PULL_READ_BUFFER_SIZE
#define GVM_JSON_PULL_READ_BUFFER_SIZE 4096 |
◆ gvm_json_path_elem_t
Path element types for the JSON pull parser.
◆ gvm_json_pull_container_type_t
Type of container the parser is currently in.
Enumerator |
---|
GVM_JSON_PULL_CONTAINER_NONE | No container / document root.
|
GVM_JSON_PULL_CONTAINER_ARRAY | Array.
|
GVM_JSON_PULL_CONTAINER_OBJECT | Object.
|
◆ gvm_json_pull_event_type_t
Event types for the JSON pull parser.
Enumerator |
---|
GVM_JSON_PULL_EVENT_UNDEFINED | |
GVM_JSON_PULL_EVENT_ARRAY_START | |
GVM_JSON_PULL_EVENT_ARRAY_END | |
GVM_JSON_PULL_EVENT_OBJECT_START | |
GVM_JSON_PULL_EVENT_OBJECT_END | |
GVM_JSON_PULL_EVENT_STRING | |
GVM_JSON_PULL_EVENT_NUMBER | |
GVM_JSON_PULL_EVENT_BOOLEAN | |
GVM_JSON_PULL_EVENT_NULL | |
GVM_JSON_PULL_EVENT_EOF | |
GVM_JSON_PULL_EVENT_ERROR | |
◆ gvm_json_pull_expect_t
Expected token state for the JSON pull parser.
Enumerator |
---|
GVM_JSON_PULL_EXPECT_UNDEFINED | Undefined state.
|
GVM_JSON_PULL_EXPECT_VALUE | Expect start of a value.
|
GVM_JSON_PULL_EXPECT_KEY | Expect start of a key.
|
GVM_JSON_PULL_EXPECT_COMMA | Expect comma or container end brace.
|
GVM_JSON_PULL_EXPECT_EOF | Expect end of file.
|
◆ gvm_json_path_to_string()
gchar * gvm_json_path_to_string |
( |
GQueue * | path | ) |
|
Converts a path as used by a JSON pull parser to a JSONPath string.
- Parameters
-
[in] | path | The path to convert |
- Returns
- Newly allocated string of the path in JSONPath bracket notation
◆ gvm_json_pull_event_cleanup()
Frees all data of JSON pull event data structure.
- Parameters
-
[in] | event | The event structure to clean up |
◆ gvm_json_pull_event_init()
Initializes a JSON pull event data structure.
- Parameters
-
[in] | event | The event structure to initialize |
◆ gvm_json_pull_expand_container()
Expands the current array or object of a JSON pull parser.
This should be called after an array or object start event.
- Parameters
-
[in] | parser | Parser to get the current container element from |
[out] | error_message | Error message output |
- Returns
- The expanded container as a cJSON object if successful, else NULL
◆ gvm_json_pull_parser_cleanup()
Frees the data of a JSON pull parser.
- Parameters
-
[in] | parser | The parser data structure to free the data of |
◆ gvm_json_pull_parser_init()
Initializes a JSON pull parser with default buffer sizes.
- Parameters
-
[in] | parser | The parser data structure to initialize |
[in] | input_stream | The JSON input stream |
◆ gvm_json_pull_parser_init_full()
void gvm_json_pull_parser_init_full |
( |
gvm_json_pull_parser_t * | parser, |
|
|
FILE * | input_stream, |
|
|
size_t | parse_buffer_limit, |
|
|
size_t | read_buffer_size ) |
Initializes a JSON pull parser.
- Parameters
-
[in] | parser | The parser data structure to initialize |
[in] | input_stream | The JSON input stream |
[in] | parse_buffer_limit | Maximum buffer size for parsing values |
[in] | read_buffer_size | Buffer size for reading from the stream |
◆ gvm_json_pull_parser_next()
Get the next event from a JSON pull parser.
Note: This invalidates previous event data like the cJSON value.
- Parameters
-
[in] | parser | The JSON pull parser to process until the next event |
[in] | event | Structure to store event data in. |
◆ gvm_json_pull_path_elem_free()
Frees a JSON path element.
- Parameters
-
[in] | elem | The element to free |
◆ gvm_json_pull_path_elem_new()
Creates a new JSON path element.
- Parameters
-
[in] | parent_type | Type of the parent (array, object, none/root) |
[in] | depth | The depth in the document tree |
- Returns
- The newly allocated path element