19#ifndef _ASTERISK_JSON_H
20#define _ASTERISK_JSON_H
224#define AST_JSON_UTF8_VALIDATE(str) (ast_json_utf8_check(str) ? (str) : "")
600#define ast_json_object_string_get(object, key) ast_json_string_get(ast_json_object_get(object, key))
609#define ast_json_object_integer_get(object, key) ast_json_integer_get(ast_json_object_get(object, key))
618#define ast_json_object_real_get(object, key) ast_json_real_get(ast_json_object_get(object, key))
810#define ast_json_dump_string(root) ast_json_dump_string_format(root, AST_JSON_COMPACT)
834#define ast_json_dump_string_sorted(root) ast_json_dump_string_format(root, AST_JSON_SORTED)
836#define ast_json_dump_str(root, dst) ast_json_dump_str_format(root, dst, AST_JSON_COMPACT)
852#define ast_json_dump_file(root, output) ast_json_dump_file_format(root, output, AST_JSON_COMPACT)
866#define ast_json_dump_new_file(root, path) ast_json_dump_new_file_format(root, path, AST_JSON_COMPACT)
880#define AST_JSON_ERROR_TEXT_LENGTH 160
881#define AST_JSON_ERROR_SOURCE_LENGTH 80
static int input(yyscan_t yyscanner)
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
int ast_json_array_remove(struct ast_json *array, size_t index)
Remove an element from an array.
int ast_json_object_clear(struct ast_json *object)
Delete all elements from a 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_object_iter_value(struct ast_json_iter *iter)
Get the value from an iterator.
struct ast_json * ast_json_dialplan_cep(const char *context, const char *exten, int priority)
Construct a context/exten/priority as JSON.
struct ast_json * ast_json_deep_copy(const struct ast_json *value)
Copy a JSON value, and its children.
int ast_json_is_array(const struct ast_json *value)
Check if value is JSON array.
int ast_json_array_clear(struct ast_json *array)
Remove all elements from an array.
struct ast_json * ast_json_string_create(const char *value)
Construct a JSON string from 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.
enum ast_json_type ast_json_typeof(const struct ast_json *value)
Get the type of value.
struct ast_json * ast_json_null(void)
Get the JSON null value.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
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_next(struct ast_json *object, struct ast_json_iter *iter)
Get the next iterator.
int ast_json_array_set(struct ast_json *array, size_t index, struct ast_json *value)
Change an element in an array.
int ast_json_array_append(struct ast_json *array, struct ast_json *value)
Append to an array.
int ast_json_equal(const struct ast_json *lhs, const struct ast_json *rhs)
Compare two JSON objects.
int ast_json_is_false(const struct ast_json *value)
Check if value is JSON false.
size_t ast_json_object_size(struct ast_json *object)
Get size of JSON object.
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
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_name_number(const char *name, const char *number)
Common JSON rendering functions for common 'objects'.
const char * ast_json_typename(enum ast_json_type type)
Get the string name for the given type.
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.
int ast_json_integer_set(struct ast_json *integer, intmax_t value)
Set the value of a JSON integer.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
int ast_json_array_insert(struct ast_json *array, size_t index, struct ast_json *value)
Insert into an array.
struct ast_json * ast_json_timeval(const struct timeval tv, const char *zone)
Construct a timeval as JSON.
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.
struct ast_json * ast_json_boolean(int value)
Get the JSON boolean corresponding to value.
struct ast_json * ast_json_integer_create(intmax_t value)
Create a JSON integer.
struct ast_json * ast_json_vstringf(const char *format, va_list args)
Create a JSON string, vprintf style.
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_array_create(void)
Create a empty JSON array.
struct ast_json * ast_json_party_id(struct ast_party_id *party)
Construct an ast_party_id as JSON.
#define AST_JSON_ERROR_TEXT_LENGTH
void * ast_json_malloc(size_t size)
Asterisk's custom JSON allocator. Exposed for use by unit tests.
void ast_json_reset_alloc_funcs(void)
Change alloc funcs back to the resource module defaults.
struct ast_json * ast_json_object_create_vars(const struct ast_variable *variables, const char *excludes)
Create a new JSON object using the given variables.
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_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.
struct ast_json * ast_json_true(void)
Get the JSON true value.
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.
int ast_json_object_del(struct ast_json *object, const char *key)
Delete a field from a JSON object.
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_array_extend(struct ast_json *array, struct ast_json *tail)
Append all elements from tail to array.
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.
ast_json_type
Valid types of a JSON element.
int ast_json_utf8_check_len(const char *str, size_t len)
Check the string of the given length for UTF-8 format.
int ast_json_real_set(struct ast_json *real, double value)
Set the value of a JSON real number.
struct ast_json * ast_json_load_file(FILE *input, struct ast_json_error *error)
Parse a FILE into JSON object or array.
ast_json_encoding_format
Encoding format type.
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_ref(struct ast_json *value)
Increase refcount on value.
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.
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
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.
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.
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.
ast_json_to_ast_vars_code
@ AST_JSON_TO_AST_VARS_CODE_INVALID_TYPE
Conversion failed because invalid value type supplied.
@ AST_JSON_TO_AST_VARS_CODE_SUCCESS
Conversion successful.
@ AST_JSON_TO_AST_VARS_CODE_OOM
Conversion failed because of allocation failure. (Out Of Memory)
struct ast_json * ast_json_object_get(struct ast_json *object, const char *key)
Get a field from a JSON object.
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().
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.
int ast_json_init(void)
Initialize the JSON library.
intmax_t ast_json_integer_get(const struct ast_json *integer)
Get the value from a JSON integer.
int ast_json_is_object(const struct ast_json *value)
Check if value is JSON object.
struct ast_json * ast_json_channel_vars(struct varshead *channelvars)
Construct a JSON object from a ast_var_t list.
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_copy(const struct ast_json *value)
Copy a JSON value, but not its children.
struct ast_json * ast_json_real_create(double value)
Create a JSON real number.
int ast_json_is_true(const struct ast_json *value)
Check if value is JSON true.
AST_JSON_INT_T ast_json_int_t
Primarily used to cast when packing to an "I" type.
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.
int ast_json_utf8_check(const char *str)
Check the nul terminated string for UTF-8 format.
struct ast_json * ast_json_vpack(char const *format, va_list ap)
Helper for creating complex JSON values simply.
int ast_json_object_update(struct ast_json *object, struct ast_json *other)
Update object with all of the fields of other.
size_t ast_json_array_size(const struct ast_json *array)
Get the size of a JSON array.
int ast_json_is_null(const struct ast_json *value)
Check if value is JSON null.
double ast_json_real_get(const struct ast_json *real)
Get the value from a JSON real number.
int ast_json_string_set(struct ast_json *string, const char *value)
Change the value of a JSON string.
const char * app_name(struct ast_app *app)
JSON parsing error information.
char source[AST_JSON_ERROR_TEXT_LENGTH]
char text[AST_JSON_ERROR_TEXT_LENGTH]
Iterator for JSON object key/values.
Abstract JSON element (object, array, string, int, ...).
Information needed to identify an endpoint in a call.
Socket address structure.
Support for dynamic strings.
Structure for variables, used for configurations and for channel variables.
int error(const char *format,...)