19 #ifndef _ASTERISK_JSON_H 20 #define _ASTERISK_JSON_H 224 #define AST_JSON_UTF8_VALIDATE(str) (ast_json_utf8_check(str) ? (str) : "") 573 #define ast_json_object_string_get(object, key) ast_json_string_get(ast_json_object_get(object, key)) 763 #define ast_json_dump_string(root) ast_json_dump_string_format(root, AST_JSON_COMPACT) 778 #define ast_json_dump_str(root, dst) ast_json_dump_str_format(root, dst, AST_JSON_COMPACT) 794 #define ast_json_dump_file(root, output) ast_json_dump_file_format(root, output, AST_JSON_COMPACT) 808 #define ast_json_dump_new_file(root, path) ast_json_dump_new_file_format(root, path, AST_JSON_COMPACT) 822 #define AST_JSON_ERROR_TEXT_LENGTH 160 823 #define AST_JSON_ERROR_SOURCE_LENGTH 80 int ast_json_dump_file_format(struct ast_json *root, FILE *output, enum ast_json_encoding_format format)
Encode a JSON value to a FILE.
int ast_json_array_extend(struct ast_json *array, struct ast_json *tail)
Append all elements from tail to array.
Information needed to identify an endpoint in a call.
struct ast_json * ast_json_dialplan_cep(const char *context, const char *exten, int priority)
Construct a context/exten/priority as JSON.
static char exten[AST_MAX_EXTENSION]
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
struct ast_json * ast_json_party_id(struct ast_party_id *party)
Construct an ast_party_id as JSON.
struct ast_json * ast_json_load_buf(const char *buffer, size_t buflen, struct ast_json_error *error)
Parse buffer with known length into a JSON object or array.
char text[AST_JSON_ERROR_TEXT_LENGTH]
size_t ast_json_object_size(struct ast_json *object)
Get size of JSON object.
int ast_json_array_set(struct ast_json *array, size_t index, struct ast_json *value)
Change an element in an array.
struct ast_json_payload * ast_json_payload_create(struct ast_json *json)
Create an ao2 object to pass json blobs as data payloads for stasis.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
int ast_json_object_clear(struct ast_json *object)
Delete all elements from a JSON object.
struct ast_json * ast_json_vpack(char const *format, va_list ap)
Helper for creating complex JSON values simply.
int ast_json_array_clear(struct ast_json *array)
Remove all elements from an array.
Iterator for JSON object key/values.
int ast_json_object_update(struct ast_json *object, struct ast_json *other)
Update object with all of the fields of other.
int ast_json_object_update_existing(struct ast_json *object, struct ast_json *other)
Update existing fields in object with the fields of other.
int ast_json_object_del(struct ast_json *object, const char *key)
Delete a field from a JSON object.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
void ast_json_free(void *p)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
struct ast_json_iter * ast_json_object_iter(struct ast_json *object)
Get an iterator pointing to the first field in a JSON object.
int ast_json_is_true(const struct ast_json *value)
Check if value is JSON true.
Structure for variables, used for configurations and for channel variables.
ast_json_type
Valid types of a JSON element.
struct ast_json * ast_json_stringf(const char *format,...)
Create a JSON string, printf style.
struct ast_json * ast_json_load_string(const char *input, struct ast_json_error *error)
Parse null terminated string into a JSON object or array.
struct ast_json * ast_json_load_str(const struct ast_str *input, struct ast_json_error *error)
Parse ast_str into a JSON object or array.
int ast_json_is_null(const struct ast_json *value)
Check if value is JSON null.
static int input(yyscan_t yyscanner)
#define AST_JSON_ERROR_TEXT_LENGTH
Socket address structure.
JSON parsing error information.
int ast_json_array_insert(struct ast_json *array, size_t index, struct ast_json *value)
Insert into an array.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
struct ast_json * ast_json_dialplan_cep_app(const char *context, const char *exten, int priority, const char *app_name, const char *app_data)
Construct a context/exten/priority/application/application_data as JSON.
struct ast_json * ast_json_null(void)
Get the JSON null value.
Conversion failed because invalid value type supplied.
struct ast_json * ast_json_channel_vars(struct varshead *channelvars)
Construct a JSON object from a ast_var_t list.
struct ast_json * ast_json_name_number(const char *name, const char *number)
Common JSON rendering functions for common 'objects'.
struct ast_json * ast_json_object_iter_value(struct ast_json_iter *iter)
Get the value from an iterator.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from value.
int ast_json_object_iter_set(struct ast_json *object, struct ast_json_iter *iter, struct ast_json *value)
Set the value of the field pointed to by an iterator.
int ast_json_real_set(struct ast_json *real, double value)
Set the value of a JSON real number.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
const char * ast_json_object_iter_key(struct ast_json_iter *iter)
Get the key from an iterator.
int ast_json_is_false(const struct ast_json *value)
Check if value is JSON false.
struct ast_json * ast_json_vstringf(const char *format, va_list args)
Create a JSON string, vprintf style.
char * ast_json_dump_string_format(struct ast_json *root, enum ast_json_encoding_format format)
Encode a JSON value to a string.
struct ast_json * ast_json_array_create(void)
Create a empty JSON array.
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
int ast_json_dump_str_format(struct ast_json *root, struct ast_str **dst, enum ast_json_encoding_format format)
Encode a JSON value to an ast_str.
struct ast_json * ast_json_load_new_file(const char *path, struct ast_json_error *error)
Parse file at path into JSON object or array.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
int ast_json_integer_set(struct ast_json *integer, intmax_t value)
Set the value of a JSON integer.
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
int ast_json_utf8_check_len(const char *str, size_t len)
Check the string of the given length for UTF-8 format.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
const char * app_name(struct ast_app *app)
enum ast_json_to_ast_vars_code ast_json_to_ast_variables(struct ast_json *json_variables, struct ast_variable **variables)
Convert a ast_json list of key/value pair tuples into a ast_variable list.
Conversion failed because of allocation failure. (Out Of Memory)
int ast_json_array_remove(struct ast_json *array, size_t index)
Remove an element from an array.
void ast_json_set_alloc_funcs(void *(*malloc_fn)(size_t), void(*free_fn)(void *))
Set custom allocators instead of the standard ast_malloc() and ast_free().
struct ast_json * ast_json_load_file(FILE *input, struct ast_json_error *error)
Parse a FILE into JSON object or array.
double ast_json_real_get(const struct ast_json *real)
Get the value from a JSON real number.
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
int ast_json_object_update_missing(struct ast_json *object, struct ast_json *other)
Add new fields to object with the fields of other.
const char * ast_json_typename(enum ast_json_type type)
Get the string name for the given type.
char source[AST_JSON_ERROR_TEXT_LENGTH]
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
struct ast_json * ast_json_false(void)
Get the JSON false value.
struct ast_json * ast_json_ipaddr(const struct ast_sockaddr *addr, enum ast_transport transport_type)
Construct an IP address as JSON.
struct ast_json * ast_json_real_create(double value)
Create a JSON real number.
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
int ast_json_utf8_check(const char *str)
Check the nul terminated string for UTF-8 format.
int ast_json_equal(const struct ast_json *lhs, const struct ast_json *rhs)
Compare two JSON objects.
int ast_json_init(void)
Initialize the JSON library.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
Abstract JSON element (object, array, string, int, ...).
struct ast_json * ast_json_boolean(int value)
Get the JSON boolean corresponding to value.
int ast_json_dump_new_file_format(struct ast_json *root, const char *path, enum ast_json_encoding_format format)
Encode a JSON value to a file at the given location.
int error(const char *format,...)
void * ast_json_malloc(size_t size)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
struct ast_json_iter * ast_json_object_iter_at(struct ast_json *object, const char *key)
Get an iterator pointing to a specified key in object.
static char context[AST_MAX_CONTEXT]
int ast_json_string_set(struct ast_json *string, const char *value)
Change the value of a JSON string.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
static snd_pcm_format_t format
ast_json_to_ast_vars_code
struct ast_json * ast_json_array_get(const struct ast_json *array, size_t index)
Get an element from an array.
struct ast_json * ast_json_copy(const struct ast_json *value)
Copy a JSON value, but not its children.
void ast_json_reset_alloc_funcs(void)
Change alloc funcs back to the resource module defaults.
struct ast_json * ast_json_true(void)
Get the JSON true value.
struct ast_json * ast_json_deep_copy(const struct ast_json *value)
Copy a JSON value, and its children.
ast_json_encoding_format
Encoding format type.
struct ast_json_iter * ast_json_object_iter_next(struct ast_json *object, struct ast_json_iter *iter)
Get the next iterator.
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.