Go to the source code of this file.
|
| GRN_API grn_json_parser * | grn_json_parser_open (grn_ctx *ctx, grn_obj *input, grn_obj *output) |
| | Open a new JSON parser.
|
| |
| GRN_API grn_rc | grn_json_parser_close (grn_ctx *ctx, grn_json_parser *parser) |
| | Close a JSON parser.
|
| |
| GRN_API grn_rc | grn_json_parser_parse (grn_ctx *ctx, grn_json_parser *parser) |
| | Parse the given JSON text.
|
| |
| GRN_API grn_json_reader * | grn_json_reader_open (grn_ctx *ctx, grn_obj *json) |
| | Open a new JSON reader.
|
| |
| GRN_API grn_rc | grn_json_reader_close (grn_ctx *ctx, grn_json_reader *reader) |
| | Close a JSON reader.
|
| |
| GRN_API const char * | grn_json_value_type_to_string (grn_json_value_type type) |
| | Stringify grn_json_value_type.
|
| |
| GRN_API grn_rc | grn_json_reader_next (grn_ctx *ctx, grn_json_reader *reader) |
| | Move to the next value.
|
| |
| GRN_API grn_json_value_type | grn_json_reader_get_type (grn_ctx *ctx, grn_json_reader *reader) |
| | Return the current value type.
|
| |
| GRN_API grn_obj * | grn_json_reader_get_value (grn_ctx *ctx, grn_json_reader *reader) |
| | Return the current value.
|
| |
| GRN_API size_t | grn_json_reader_get_size (grn_ctx *ctx, grn_json_reader *reader) |
| | Return the size of the current value.
|
| |
| GRN_API grn_rc | grn_json_to_string (grn_ctx *ctx, grn_obj *json, grn_obj *buffer) |
| | Stringify parsed JSON.
|
| |
| GRN_API grn_json_path * | grn_json_path_open (grn_ctx *ctx, const char *path, int64_t path_length) |
| | Open a new JSONPath.
|
| |
| GRN_API grn_rc | grn_json_path_close (grn_ctx *ctx, grn_json_path *path) |
| | Close a JSONPath.
|
| |
| GRN_API grn_rc | grn_json_extract (grn_ctx *ctx, grn_obj *json, grn_json_path *path, grn_obj *values) |
| | Extract values specified by JSONPath in a parsed JSON.
|
| |
◆ grn_json_parser
◆ grn_json_path
JSONPath that represents path of values in JSON.
- Since
- 16.0.6
◆ grn_json_reader
JSON reader that readers values from parses JSON (GRN_DB_JSON).
- Since
- 15.2.2
◆ grn_json_value_type
JSON value type.
- Since
- 15.2.2
| Enumerator |
|---|
| GRN_JSON_VALUE_UNKNOWN | |
| GRN_JSON_VALUE_NULL | |
| GRN_JSON_VALUE_FALSE | |
| GRN_JSON_VALUE_TRUE | |
| GRN_JSON_VALUE_INT64 | |
| GRN_JSON_VALUE_FLOAT | |
| GRN_JSON_VALUE_STRING | |
| GRN_JSON_VALUE_ARRAY | |
| GRN_JSON_VALUE_OBJECT | |
◆ grn_json_extract()
Extract values specified by JSONPath in a parsed JSON.
- Parameters
-
| ctx | The context object. |
| json | The JSON to extract. |
| path | The JSONPath that specifies values. |
| values | The output values. This must be initialized by GRN_VALUE_VAR_SIZE_INIT(&values, GRN_OBJ_VECTOR, GRN_ID_NIL) or grn_obj_open(ctx, GRN_VECTOR, 0,
GRN_ID_NIL). |
- Returns
- GRN_SUCCESS on success, the appropriate grn_rc on error.
- Since
- 16.0.6
◆ grn_json_parser_close()
Close a JSON parser.
- Parameters
-
| ctx | The context object. |
| parser | The parser to close. |
- Returns
- GRN_SUCCESS on success, the appropriate grn_rc on error.
- Since
- 15.2.2
◆ grn_json_parser_open()
Open a new JSON parser.
- Parameters
-
| ctx | The context object. |
| input | The JSON text. |
| output | The parsed JSON. |
- Returns
- A newly created JSON parser on success,
NULL on error.
- Since
- 15.2.2
◆ grn_json_parser_parse()
Parse the given JSON text.
- Parameters
-
| ctx | The context object. |
| parser | The parser. |
- Returns
- GRN_SUCCESS on success, the appropriate grn_rc on error.
- Since
- 15.2.2
◆ grn_json_path_close()
Close a JSONPath.
- Parameters
-
| ctx | The context object. |
| path | The path to close. |
- Returns
- GRN_SUCCESS on success, the appropriate grn_rc on error.
- Since
- 16.0.6
◆ grn_json_path_open()
Open a new JSONPath.
- Parameters
-
| ctx | The context object. |
| path | The JSONPath to parse. |
| path_length | The byte size of path. You can use -1 if path is a \0-terminated string. |
- Returns
- A newly created JSONPath on success,
NULL on error.
- Since
- 16.0.6
◆ grn_json_reader_close()
Close a JSON reader.
- Parameters
-
| ctx | The context object. |
| reader | The reader to close. |
- Returns
- GRN_SUCCESS on success, the appropriate grn_rc on error.
- Since
- 15.2.2
◆ grn_json_reader_get_size()
Return the size of the current value.
- Parameters
-
| ctx | The context object. |
| reader | The reader. |
- Returns
- If the current value is an array, the number of elements.
If the current value is an object, the number of members.
Otherwise, `0`.
- Since
- 15.2.2
◆ grn_json_reader_get_type()
Return the current value type.
- Parameters
-
| ctx | The context object. |
| reader | The reader. |
- Returns
- If the current value is
null, GRN_JSON_VALUE_NULL. If the current value is `false`, \ref GRN_JSON_VALUE_FALSE.
If the current value is `true`, \ref GRN_JSON_VALUE_TRUE.
If the current value is an integer, \ref
GRN_JSON_VALUE_INT64.
If the current value is a floating-point number, \ref
GRN_JSON_VALUE_FLOAT.
If the current value is a string, \ref
GRN_JSON_VALUE_STRING.
If the current value is an array, \ref
GRN_JSON_VALUE_ARRAY.
If the current value is an array, \ref
GRN_JSON_VALUE_OBJECT.
Otherwise, \ref GRN_JSON_VALUE_UNKNOWN.
- Since
- 15.2.2
◆ grn_json_reader_get_value()
Return the current value.
This is owned by the reader. Caller must not free it. The returned value is invalid when you call grn_json_reader_next. If you want to use this after the next grn_json_reader_next call, you need to copy this by yourself.
- Parameters
-
| ctx | The context object. |
| reader | The reader. |
- Returns
- If the current value is
null, GRN_DB_VOID bulk. If the current value is `false` or `true`, \ref GRN_DB_BOOL
bulk.
If the current value is an integer, \ref GRN_DB_INT64 bulk.
If the current value is a floating-point number, \ref
GRN_DB_FLOAT bulk.
If the current value is a string, \ref GRN_DB_TEXT bulk.
Otherwise, `NULL`. You can get array elements and object
members by calling \ref grn_json_reader_next.
- Since
- 15.2.2
◆ grn_json_reader_next()
Move to the next value.
The initial state doesn't focus on any value. You must call this at least once. This returns GRN_END_OF_DATA when all values are processed. So you can use the following loop:
if (!reader) {
}
while (true) {
break;
}
break;
}
}
grn_rc
Definition groonga.h:61
@ GRN_SUCCESS
Success (0)
Definition groonga.h:63
@ GRN_END_OF_DATA
Definition groonga.h:64
GRN_API grn_rc grn_json_reader_close(grn_ctx *ctx, grn_json_reader *reader)
Close a JSON reader.
struct _grn_json_reader grn_json_reader
JSON reader that readers values from parses JSON (GRN_DB_JSON).
Definition json.h:81
GRN_API grn_json_reader * grn_json_reader_open(grn_ctx *ctx, grn_obj *json)
Open a new JSON reader.
GRN_API grn_rc grn_json_reader_next(grn_ctx *ctx, grn_json_reader *reader)
Move to the next value.
- Parameters
-
| ctx | The context object. |
| reader | The reader. |
- Returns
- GRN_SUCCESS on success, GRN_END_OF_DATA on all processed, the appropriate grn_rc on error.
- Since
- 15.2.2
◆ grn_json_reader_open()
Open a new JSON reader.
- Parameters
-
| ctx | The context object. |
| json | The parsed JSON. |
- Returns
- A newly created JSON reader on success,
NULL on error.
- Since
- 15.2.2
◆ grn_json_to_string()
Stringify parsed JSON.
- Parameters
-
| ctx | The context object. |
| json | The JSON to stringify. |
| buffer | The output buffer. |
- Returns
- GRN_SUCCESS on success, the appropriate grn_rc on error.
- Since
- 15.2.2
◆ grn_json_value_type_to_string()
Stringify grn_json_value_type.
- Parameters
-
- Returns
- The string representation of
type.
- Since
- 16.0.1