Asterisk - The Open Source Telephony Project
21.4.1
|
Asterisk JSON abstraction layer. More...
#include "asterisk/netsock2.h"
Go to the source code of this file.
Data Structures | |
struct | ast_json_error |
JSON parsing error information. More... | |
struct | ast_json_payload |
Functions | |
struct ast_json * | ast_json_true (void) |
Get the JSON true value. More... | |
struct ast_json * | ast_json_false (void) |
Get the JSON false value. More... | |
struct ast_json * | ast_json_boolean (int value) |
Get the JSON boolean corresponding to value. More... | |
struct ast_json * | ast_json_null (void) |
Get the JSON null value. More... | |
int | ast_json_is_array (const struct ast_json *value) |
Check if value is JSON array. More... | |
int | ast_json_is_object (const struct ast_json *value) |
Check if value is JSON object. More... | |
int | ast_json_is_true (const struct ast_json *value) |
Check if value is JSON true. More... | |
int | ast_json_is_false (const struct ast_json *value) |
Check if value is JSON false. More... | |
int | ast_json_is_null (const struct ast_json *value) |
Check if value is JSON null. More... | |
struct ast_json * | ast_json_string_create (const char *value) |
Construct a JSON string from value. More... | |
const char * | ast_json_string_get (const struct ast_json *string) |
Get the value of a JSON string. More... | |
int | ast_json_string_set (struct ast_json *string, const char *value) |
Change the value of a JSON string. More... | |
struct ast_json * | ast_json_stringf (const char *format,...) |
Create a JSON string, printf style. More... | |
struct ast_json * | ast_json_vstringf (const char *format, va_list args) |
Create a JSON string, vprintf style. More... | |
struct ast_json * | ast_json_integer_create (intmax_t value) |
Create a JSON integer. More... | |
intmax_t | ast_json_integer_get (const struct ast_json *integer) |
Get the value from a JSON integer. More... | |
int | ast_json_integer_set (struct ast_json *integer, intmax_t value) |
Set the value of a JSON integer. More... | |
struct ast_json * | ast_json_real_create (double value) |
Create a JSON real number. More... | |
double | ast_json_real_get (const struct ast_json *real) |
Get the value from a JSON real number. More... | |
int | ast_json_real_set (struct ast_json *real, double value) |
Set the value of a JSON real number. More... | |
struct ast_json * | ast_json_array_create (void) |
Create a empty JSON array. More... | |
size_t | ast_json_array_size (const struct ast_json *array) |
Get the size of a JSON array. More... | |
struct ast_json * | ast_json_array_get (const struct ast_json *array, size_t index) |
Get an element from an array. More... | |
int | ast_json_array_set (struct ast_json *array, size_t index, struct ast_json *value) |
Change an element in an array. More... | |
int | ast_json_array_append (struct ast_json *array, struct ast_json *value) |
Append to an array. More... | |
int | ast_json_array_insert (struct ast_json *array, size_t index, struct ast_json *value) |
Insert into an array. More... | |
int | ast_json_array_remove (struct ast_json *array, size_t index) |
Remove an element from an array. More... | |
int | ast_json_array_clear (struct ast_json *array) |
Remove all elements from an array. More... | |
int | ast_json_array_extend (struct ast_json *array, struct ast_json *tail) |
Append all elements from tail to array. More... | |
int | ast_json_equal (const struct ast_json *lhs, const struct ast_json *rhs) |
Compare two JSON objects. More... | |
struct ast_json * | ast_json_copy (const struct ast_json *value) |
Copy a JSON value, but not its children. More... | |
struct ast_json * | ast_json_deep_copy (const struct ast_json *value) |
Copy a JSON value, and its children. More... | |
typedef AST_JSON_INT_T | ast_json_int_t |
Primarily used to cast when packing to an "I" type. | |
int | ast_json_init (void) |
Initialize the JSON library. | |
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(). More... | |
void | ast_json_reset_alloc_funcs (void) |
Change alloc funcs back to the resource module defaults. More... | |
void * | ast_json_malloc (size_t size) |
Asterisk's custom JSON allocator. Exposed for use by unit tests. More... | |
void | ast_json_free (void *p) |
Asterisk's custom JSON allocator. Exposed for use by unit tests. More... | |
struct ast_json * | ast_json_ref (struct ast_json *value) |
Increase refcount on value. More... | |
void | ast_json_unref (struct ast_json *value) |
Decrease refcount on value. If refcount reaches zero, value is freed. More... | |
enum | ast_json_type { AST_JSON_OBJECT, AST_JSON_ARRAY, AST_JSON_STRING, AST_JSON_INTEGER, AST_JSON_REAL, AST_JSON_TRUE, AST_JSON_FALSE, AST_JSON_NULL } |
Valid types of a JSON element. More... | |
enum ast_json_type | ast_json_typeof (const struct ast_json *value) |
Get the type of value. More... | |
const char * | ast_json_typename (enum ast_json_type type) |
Get the string name for the given type. More... | |
#define | AST_JSON_UTF8_VALIDATE(str) (ast_json_utf8_check(str) ? (str) : "") |
Check str for UTF-8 and replace with an empty string if fails the check. More... | |
int | ast_json_utf8_check_len (const char *str, size_t len) |
Check the string of the given length for UTF-8 format. More... | |
int | ast_json_utf8_check (const char *str) |
Check the nul terminated string for UTF-8 format. More... | |
#define | ast_json_object_string_get(object, key) ast_json_string_get(ast_json_object_get(object, key)) |
Get a string field from a JSON object. More... | |
#define | ast_json_object_integer_get(object, key) ast_json_integer_get(ast_json_object_get(object, key)) |
Get an integer field from a JSON object. More... | |
#define | ast_json_object_real_get(object, key) ast_json_real_get(ast_json_object_get(object, key)) |
Get a double field from a JSON object. More... | |
struct ast_json * | ast_json_object_create (void) |
Create a new JSON object. More... | |
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. More... | |
size_t | ast_json_object_size (struct ast_json *object) |
Get size of JSON object. More... | |
struct ast_json * | ast_json_object_get (struct ast_json *object, const char *key) |
Get a field from a JSON object. More... | |
int | ast_json_object_set (struct ast_json *object, const char *key, struct ast_json *value) |
Set a field in a JSON object. More... | |
int | ast_json_object_del (struct ast_json *object, const char *key) |
Delete a field from a JSON object. More... | |
int | ast_json_object_clear (struct ast_json *object) |
Delete all elements from a JSON object. More... | |
int | ast_json_object_update (struct ast_json *object, struct ast_json *other) |
Update object with all of the fields of other. More... | |
int | ast_json_object_update_existing (struct ast_json *object, struct ast_json *other) |
Update existing fields in object with the fields of other. More... | |
int | ast_json_object_update_missing (struct ast_json *object, struct ast_json *other) |
Add new fields to object with the fields of other. More... | |
struct ast_json_iter * | ast_json_object_iter (struct ast_json *object) |
Get an iterator pointing to the first field in a JSON object. More... | |
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. More... | |
struct ast_json_iter * | ast_json_object_iter_next (struct ast_json *object, struct ast_json_iter *iter) |
Get the next iterator. More... | |
const char * | ast_json_object_iter_key (struct ast_json_iter *iter) |
Get the key from an iterator. More... | |
struct ast_json * | ast_json_object_iter_value (struct ast_json_iter *iter) |
Get the value from an iterator. More... | |
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. More... | |
#define | ast_json_dump_string(root) ast_json_dump_string_format(root, AST_JSON_COMPACT) |
Encode a JSON value to a compact string. More... | |
#define | ast_json_dump_string_sorted(root) ast_json_dump_string_format(root, AST_JSON_SORTED) |
Encode a JSON value to a string, with its keys sorted. More... | |
#define | ast_json_dump_str(root, dst) ast_json_dump_str_format(root, dst, AST_JSON_COMPACT) |
#define | ast_json_dump_file(root, output) ast_json_dump_file_format(root, output, AST_JSON_COMPACT) |
#define | ast_json_dump_new_file(root, path) ast_json_dump_new_file_format(root, path, AST_JSON_COMPACT) |
#define | AST_JSON_ERROR_TEXT_LENGTH 160 |
#define | AST_JSON_ERROR_SOURCE_LENGTH 80 |
enum | ast_json_encoding_format { AST_JSON_COMPACT, AST_JSON_PRETTY, AST_JSON_SORTED } |
Encoding format type. More... | |
char * | ast_json_dump_string_format (struct ast_json *root, enum ast_json_encoding_format format) |
Encode a JSON value to a string. More... | |
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. More... | |
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 . More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
struct ast_json * | ast_json_load_file (FILE *input, struct ast_json_error *error) |
Parse a FILE into JSON object or array. More... | |
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. More... | |
struct ast_json * | ast_json_pack (char const *format,...) |
Helper for creating complex JSON values. More... | |
struct ast_json * | ast_json_vpack (char const *format, va_list ap) |
Helper for creating complex JSON values simply. More... | |
enum | ast_json_to_ast_vars_code { AST_JSON_TO_AST_VARS_CODE_SUCCESS, AST_JSON_TO_AST_VARS_CODE_INVALID_TYPE, AST_JSON_TO_AST_VARS_CODE_OOM } |
struct ast_json * | ast_json_name_number (const char *name, const char *number) |
Common JSON rendering functions for common 'objects'. More... | |
struct ast_json * | ast_json_timeval (const struct timeval tv, const char *zone) |
Construct a timeval as JSON. More... | |
struct ast_json * | ast_json_ipaddr (const struct ast_sockaddr *addr, enum ast_transport transport_type) |
Construct an IP address as JSON. More... | |
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. More... | |
struct ast_json * | ast_json_dialplan_cep (const char *context, const char *exten, int priority) |
Construct a context/exten/priority as JSON. More... | |
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. More... | |
struct ast_json * | ast_json_party_id (struct ast_party_id *party) |
Construct an ast_party_id as JSON. More... | |
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. More... | |
struct ast_json * | ast_json_channel_vars (struct varshead *channelvars) |
Construct a JSON object from a ast_var_t list. More... | |
Asterisk JSON abstraction layer.
This is a very thin wrapper around the Jansson API. For more details on it, see its docs at http://www.digip.org/jansson/doc/2.11/apiref.html.
Rather than provide the multiple ways of doing things that the Jansson API does, the Asterisk wrapper is always reference-stealing, and always NULL safe.
And by always, I mean that the reference is stolen even if the function fails. This avoids lots of conditional logic, and also avoids having to track zillions of local variables when building complex JSON objects. You can instead chain ast_json_*
calls together safely and only worry about cleaning up the root object.
In the cases where you have a need to introduce intermediate objects, just wrap them with json_ref() when passing them to other ast_json_*
() functions.
Definition in file json.h.
#define ast_json_dump_string | ( | root | ) | ast_json_dump_string_format(root, AST_JSON_COMPACT) |
Encode a JSON value to a compact string.
Returned string must be freed by calling ast_json_free().
root | JSON value. |
NULL | on error. |
Definition at line 810 of file json.h.
Referenced by ast_cel_create_event_with_time().
#define ast_json_dump_string_sorted | ( | root | ) | ast_json_dump_string_format(root, AST_JSON_SORTED) |
Encode a JSON value to a string, with its keys sorted.
Returned string must be freed by calling ast_json_free().
root | JSON value. |
NULL | on error. |
#define ast_json_object_integer_get | ( | object, | |
key | |||
) | ast_json_integer_get(ast_json_object_get(object, key)) |
#define ast_json_object_real_get | ( | object, | |
key | |||
) | ast_json_real_get(ast_json_object_get(object, key)) |
#define ast_json_object_string_get | ( | object, | |
key | |||
) | ast_json_string_get(ast_json_object_get(object, key)) |
#define AST_JSON_UTF8_VALIDATE | ( | str | ) | (ast_json_utf8_check(str) ? (str) : "") |
Check str for UTF-8 and replace with an empty string if fails the check.
Definition at line 224 of file json.h.
Referenced by ast_json_name_number(), report_fax_status(), report_receive_fax_status(), report_send_fax_status(), and set_channel_variables().
Encoding format type.
Enumerator | |
---|---|
AST_JSON_COMPACT |
Compact format, low human readability |
AST_JSON_PRETTY |
Formatted for human readability |
AST_JSON_SORTED |
Keys sorted alphabetically |
Definition at line 1109 of file json.h.
enum ast_json_type |
Append to an array.
array | JSON array to modify. |
value | New JSON value to store at the end of array. |
0 | on success. |
-1 | on error. |
Definition at line 378 of file json.c.
Referenced by add_format_information_cb(), app_to_json(), append_sound_cb(), ast_ari_bridges_list(), ast_ari_channels_list(), ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_ari_recordings_list_stored(), ast_bucket_json(), ast_endpoint_snapshot_to_json(), conf_send_event_to_participants(), process_log_list(), process_module_list(), report_receive_fax_status(), stasis_app_device_states_to_json(), stasis_app_exec(), and stasis_app_mailboxes_to_json().
int ast_json_array_clear | ( | struct ast_json * | array | ) |
struct ast_json* ast_json_array_create | ( | void | ) |
Create a empty JSON array.
NULL | on error. |
Definition at line 362 of file json.c.
Referenced by ast_ari_applications_list(), ast_ari_asterisk_list_log_channels(), ast_ari_asterisk_list_modules(), ast_ari_bridges_list(), ast_ari_channels_list(), ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_ari_recordings_list_stored(), ast_ari_sounds_list(), ast_bucket_json(), conf_send_event_to_participants(), report_receive_fax_status(), stasis_app_device_states_to_json(), stasis_app_event_filter_to_json(), and stasis_app_mailboxes_to_json().
Append all elements from tail to array.
The tail argument is not changed, so ast_json_unref() it when you are done with it.
array | JSON array to modify. |
tail | JSON array with contents to append to array. |
0 | on success. |
-1 | on error. |
Get an element from an array.
The returned element is a borrowed reference; use ast_json_ref() to safely keep a pointer to it.
array | JSON array. |
index | Zero-based index into array. |
NULL | if array not an array. if index is out of bounds. |
Definition at line 370 of file json.c.
Referenced by ast_ari_applications_subscribe_parse_body(), ast_ari_applications_unsubscribe_parse_body(), ast_ari_asterisk_get_info_parse_body(), ast_ari_asterisk_update_object(), ast_ari_bridges_add_channel_parse_body(), ast_ari_bridges_play_parse_body(), ast_ari_bridges_play_with_id_parse_body(), ast_ari_bridges_remove_channel_parse_body(), ast_ari_channels_play_parse_body(), ast_ari_channels_play_with_id_parse_body(), ast_ari_events_user_event_parse_body(), and ast_ari_validate_list().
Insert into an array.
array | JSON array to modify. |
index | Zero-based index into array. |
value | New JSON value to store in array at index. |
0 | on success. |
-1 | on error. |
int ast_json_array_remove | ( | struct ast_json * | array, |
size_t | index | ||
) |
Change an element in an array.
array | JSON array to modify. |
index | Zero-based index into array. |
value | New JSON value to store in array at index. |
0 | on success. |
-1 | on error. |
size_t ast_json_array_size | ( | const struct ast_json * | array | ) |
Get the size of a JSON array.
array | JSON array. |
0 | if array is not a JSON array. |
Definition at line 366 of file json.c.
Referenced by ast_ari_applications_list(), ast_ari_applications_subscribe_parse_body(), ast_ari_applications_unsubscribe_parse_body(), ast_ari_asterisk_get_info_parse_body(), ast_ari_asterisk_update_object(), ast_ari_bridges_add_channel_parse_body(), ast_ari_bridges_play_parse_body(), ast_ari_bridges_play_with_id_parse_body(), ast_ari_bridges_remove_channel_parse_body(), ast_ari_channels_play_parse_body(), ast_ari_channels_play_with_id_parse_body(), ast_ari_events_user_event_parse_body(), ast_ari_sounds_list(), ast_ari_validate_list(), and create_sound_blob().
struct ast_json* ast_json_boolean | ( | int | value | ) |
Get the JSON boolean corresponding to value.
Construct a JSON object from a ast_var_t
list.
channelvars | The list of ast_var_t to represent as JSON |
Definition at line 864 of file json.c.
References ast_json_object_create(), ast_json_object_set(), ast_json_string_create(), and AST_LIST_TRAVERSE.
Referenced by ast_channel_snapshot_to_json().
Copy a JSON value, but not its children.
If value is a JSON object or array, its children are shared with the returned copy.
value | JSON value to copy. |
NULL | on error. |
Copy a JSON value, and its children.
If value is a JSON object or array, they are also copied.
value | JSON value to copy. |
NULL | on error. |
struct ast_json* ast_json_dialplan_cep | ( | const char * | context, |
const char * | exten, | ||
int | priority | ||
) |
Construct a context/exten/priority as JSON.
If a NULL
is passed for context
or exten
, or -1 for priority
, the fields is set to ast_json_null().
context | Context name. |
exten | Extension. |
priority | Dialplan priority. |
context
, exten
and priority
fields Definition at line 665 of file json.c.
References ast_json_dialplan_cep_app().
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.
If a NULL
is passed for context
or exten
or app_name
or app_data
, or -1 for priority
, the fields is set to ast_json_null().
context | Context name. |
exten | Extension. |
priority | Dialplan priority. |
app_name | Application name. |
app_data | Application argument. |
context
, exten
and priority
app_name
app_data
fields Definition at line 653 of file json.c.
References ast_json_integer_create(), ast_json_null(), and ast_json_pack().
Referenced by ast_channel_snapshot_to_json(), and ast_json_dialplan_cep().
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
.
root | JSON value. |
output | File to write JSON encoding to. |
format | encoding format type. |
0 | on success. |
-1 | on error. The contents of output are undefined. |
Definition at line 526 of file json.c.
References dump_flags().
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.
root | JSON value. |
path | Path to file to write JSON encoding to. |
format | encoding format type. |
0 | on success. |
-1 | on error. The contents of output are undefined. |
Definition at line 533 of file json.c.
References dump_flags().
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.
If dst is too small, it will be grown as needed.
root | JSON value. |
dst | ast_str to store JSON encoding. |
format | encoding format type. |
0 | on success. |
-1 | on error. The contents of dst are undefined. |
Definition at line 520 of file json.c.
References dump_flags().
char* ast_json_dump_string_format | ( | struct ast_json * | root, |
enum ast_json_encoding_format | format | ||
) |
Encode a JSON value to a string.
Returned string must be freed by calling ast_json_free().
root | JSON value. |
format | encoding format type. |
NULL | on error. |
Definition at line 484 of file json.c.
References dump_flags().
Referenced by ast_ari_websocket_session_write(), and stasis_app_message_handler().
Compare two JSON objects.
Two JSON objects are equal if they are of the same type, and their contents are equal.
lhs | Value to compare. |
rhs | Other value to compare. |
True | (non-zero) if lhs and rhs are equal. |
False | (zero) if they are not. |
struct ast_json* ast_json_false | ( | void | ) |
Get the JSON false value.
The returned value is a singleton, and does not need to be ast_json_unref()'ed.
void ast_json_free | ( | void * | p | ) |
Asterisk's custom JSON allocator. Exposed for use by unit tests.
Definition at line 52 of file json.c.
Referenced by ast_ari_websocket_session_write(), ast_cel_create_event_with_time(), ast_json_reset_alloc_funcs(), and stasis_app_message_handler().
struct ast_json* ast_json_integer_create | ( | intmax_t | value | ) |
Create a JSON integer.
value | Value of the new JSON integer. |
NULL | on error. |
Definition at line 327 of file json.c.
Referenced by ast_ari_asterisk_get_info(), ast_endpoint_snapshot_to_json(), ast_json_dialplan_cep_app(), ast_rtp_convert_stats_json(), identify_module(), and stasis_app_recording_to_json().
intmax_t ast_json_integer_get | ( | const struct ast_json * | integer | ) |
Get the value from a JSON integer.
integer | JSON integer. |
0 | if integer is not a JSON integer. |
Definition at line 332 of file json.c.
Referenced by ast_ari_bridges_play_parse_body(), ast_ari_bridges_play_with_id_parse_body(), ast_ari_bridges_record_parse_body(), ast_ari_channels_continue_in_dialplan_parse_body(), ast_ari_channels_dial_parse_body(), ast_ari_channels_originate_parse_body(), ast_ari_channels_originate_with_id_parse_body(), ast_ari_channels_play_parse_body(), ast_ari_channels_play_with_id_parse_body(), ast_ari_channels_record_parse_body(), ast_ari_channels_send_dtmf_parse_body(), and ast_ari_mailboxes_update_parse_body().
int ast_json_integer_set | ( | struct ast_json * | integer, |
intmax_t | value | ||
) |
struct ast_json* ast_json_ipaddr | ( | const struct ast_sockaddr * | addr, |
enum ast_transport | transport_type | ||
) |
Construct an IP address as JSON.
XXX some comments describing the need for this here
addr | ast_sockaddr to encode |
transport_type | ast_transport to include in the address string if any. Should just be one. |
NULL | on error. |
Definition at line 682 of file json.c.
References ast_json_string_create(), ast_sockaddr_is_ipv4(), ast_sockaddr_is_ipv4_mapped(), ast_sockaddr_stringify_addr(), ast_sockaddr_stringify_port(), ast_str_append(), ast_str_buffer(), and ast_str_set().
int ast_json_is_array | ( | const struct ast_json * | value | ) |
int ast_json_is_false | ( | const struct ast_json * | value | ) |
Check if value is JSON false.
True | (non-zero) if value == ast_json_false(). |
False | (zero) otherwise. |
int ast_json_is_null | ( | const struct ast_json * | value | ) |
Check if value is JSON null.
True | (non-zero) if value == ast_json_false(). |
False | (zero) otherwise. |
Definition at line 273 of file json.c.
Referenced by ast_manager_str_from_json_object().
int ast_json_is_object | ( | const struct ast_json * | value | ) |
int ast_json_is_true | ( | const struct ast_json * | value | ) |
Check if value is JSON true.
True | (non-zero) if value == ast_json_true(). |
False | (zero) otherwise.. |
Definition at line 263 of file json.c.
Referenced by ast_ari_bridges_add_channel_parse_body(), ast_ari_bridges_record_parse_body(), ast_ari_channels_record_parse_body(), ast_ari_endpoints_refer_parse_body(), and ast_ari_endpoints_refer_to_endpoint_parse_body().
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.
buffer | Buffer to parse. | |
buflen | Length of buffer. | |
[out] | error | Filled with information on error. |
NULL | on error. |
Definition at line 585 of file json.c.
References copy_error().
Referenced by ast_ari_websocket_session_read(), and ast_http_get_json().
struct ast_json* ast_json_load_file | ( | FILE * | input, |
struct ast_json_error * | error | ||
) |
Parse a FILE
into JSON object or array.
input | FILE to parse. | |
[out] | error | Filled with information on error. |
NULL | on error. |
Definition at line 592 of file json.c.
References copy_error().
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.
path | Path of file to parse. | |
[out] | error | Filled with information on error. |
NULL | on error. |
Definition at line 604 of file json.c.
References copy_error().
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.
input | ast_str to parse. | |
[out] | error | Filled with information on error. |
NULL | on error. |
Definition at line 580 of file json.c.
References ast_json_load_string(), and ast_str_buffer().
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.
input | String to parse. | |
[out] | error | Filled with information on error. |
NULL | on error. |
Definition at line 567 of file json.c.
References copy_error().
Referenced by ast_json_load_str(), and sorcery_astdb_retrieve_fields_common().
void* ast_json_malloc | ( | size_t | size | ) |
Asterisk's custom JSON allocator. Exposed for use by unit tests.
Definition at line 47 of file json.c.
References ast_malloc.
Referenced by ast_json_reset_alloc_funcs(), and json_debug_malloc().
struct ast_json* ast_json_name_number | ( | const char * | name, |
const char * | number | ||
) |
Common JSON rendering functions for common 'objects'.
Simple name/number pair.
name | Name |
number | Number |
NULL | on error (non-UTF8 characters, NULL inputs, etc.) |
Definition at line 646 of file json.c.
References ast_json_pack(), and AST_JSON_UTF8_VALIDATE.
Referenced by ast_channel_snapshot_to_json().
struct ast_json* ast_json_null | ( | void | ) |
Get the JSON null value.
The returned value is a singleton, and does not need to be ast_json_unref()'ed.
Definition at line 248 of file json.c.
Referenced by ast_ari_recordings_get_stored_file(), ast_ari_response_accepted(), ast_ari_response_no_content(), ast_channel_publish_blob(), ast_channel_publish_cached_blob(), ast_endpoint_blob_create(), ast_json_dialplan_cep_app(), local_optimization_finished_cb(), and local_optimization_started_cb().
int ast_json_object_clear | ( | struct ast_json * | object | ) |
struct ast_json* ast_json_object_create | ( | void | ) |
Create a new JSON object.
NULL | on error. |
Definition at line 399 of file json.c.
Referenced by ast_ari_asterisk_get_info(), ast_ari_asterisk_get_module(), ast_bucket_file_json(), ast_json_channel_vars(), ast_json_object_create_vars(), ast_rtp_convert_stats_json(), ast_sorcery_objectset_json_create(), and stun_monitor_request().
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.
variables | A list of Asterisk variables |
excludes | Comma separated string of variable names to exclude (optional) |
NULL | on error. |
Definition at line 877 of file json.c.
References ast_in_delimited_string(), ast_json_object_create(), ast_json_object_set(), ast_json_string_create(), ast_variable::name, ast_variable::next, and ast_variable::value.
int ast_json_object_del | ( | struct ast_json * | object, |
const char * | key | ||
) |
Get a field from a JSON object.
The returned element is a borrowed reference; use ast_json_ref() to safely keep a pointer to it.
object | JSON object. |
key | Key of field to look up. |
NULL | on error. |
Definition at line 407 of file json.c.
Referenced by app_send(), app_to_json(), ast_ari_applications_subscribe_parse_body(), ast_ari_applications_unsubscribe_parse_body(), ast_ari_asterisk_add_log_parse_body(), ast_ari_asterisk_get_global_var_parse_body(), ast_ari_asterisk_get_info_parse_body(), ast_ari_asterisk_set_global_var_parse_body(), ast_ari_asterisk_update_object(), ast_ari_bridges_add_channel_parse_body(), ast_ari_bridges_create_parse_body(), ast_ari_bridges_create_with_id_parse_body(), ast_ari_bridges_play_parse_body(), ast_ari_bridges_play_with_id_parse_body(), ast_ari_bridges_record_parse_body(), ast_ari_bridges_remove_channel_parse_body(), ast_ari_bridges_start_moh_parse_body(), ast_ari_channels_continue_in_dialplan_parse_body(), ast_ari_channels_create(), ast_ari_channels_create_parse_body(), ast_ari_channels_dial_parse_body(), ast_ari_channels_external_media(), ast_ari_channels_external_media_parse_body(), ast_ari_channels_get_channel_var_parse_body(), ast_ari_channels_hangup_parse_body(), ast_ari_channels_move_parse_body(), ast_ari_channels_mute_parse_body(), ast_ari_channels_originate(), ast_ari_channels_originate_parse_body(), ast_ari_channels_originate_with_id(), ast_ari_channels_originate_with_id_parse_body(), ast_ari_channels_play_parse_body(), ast_ari_channels_play_with_id_parse_body(), ast_ari_channels_record_parse_body(), ast_ari_channels_redirect_parse_body(), ast_ari_channels_send_dtmf_parse_body(), ast_ari_channels_set_channel_var_parse_body(), ast_ari_channels_snoop_channel_parse_body(), ast_ari_channels_snoop_channel_with_id_parse_body(), ast_ari_channels_start_moh_parse_body(), ast_ari_channels_unmute_parse_body(), ast_ari_device_states_update_parse_body(), ast_ari_endpoints_refer_parse_body(), ast_ari_endpoints_refer_to_endpoint_parse_body(), ast_ari_endpoints_send_message(), ast_ari_endpoints_send_message_parse_body(), ast_ari_endpoints_send_message_to_endpoint(), ast_ari_endpoints_send_message_to_endpoint_parse_body(), ast_ari_events_user_event(), ast_ari_events_user_event_parse_body(), ast_ari_mailboxes_update_parse_body(), ast_ari_playbacks_control_parse_body(), ast_ari_recordings_copy_stored_parse_body(), ast_ari_sounds_list_parse_body(), ast_ari_validate_event(), ast_ari_validate_message(), ast_endpoint_snapshot_to_json(), channel_dial_cb(), conf_send_event_to_participants(), create_sound_blob(), handle_dial_message(), mwi_app_event_cb(), stasis_app_exec(), and stasis_app_message_handler().
struct ast_json_iter* ast_json_object_iter | ( | struct ast_json * | object | ) |
Get an iterator pointing to the first field in a JSON object.
The order of the fields in an object are not specified. However, iterating forward from this iterator will cover all fields in object. Adding or removing fields from object may invalidate its iterators.
object | JSON object. |
NULL | object is empty. on error. |
Definition at line 439 of file json.c.
Referenced by ast_ari_validate_application(), ast_ari_validate_application_move_failed(), ast_ari_validate_application_replaced(), ast_ari_validate_asterisk_info(), ast_ari_validate_asterisk_ping(), ast_ari_validate_bridge(), ast_ari_validate_bridge_attended_transfer(), ast_ari_validate_bridge_blind_transfer(), ast_ari_validate_bridge_created(), ast_ari_validate_bridge_destroyed(), ast_ari_validate_bridge_merged(), ast_ari_validate_bridge_video_source_changed(), ast_ari_validate_build_info(), ast_ari_validate_caller_id(), ast_ari_validate_channel(), ast_ari_validate_channel_caller_id(), ast_ari_validate_channel_connected_line(), ast_ari_validate_channel_created(), ast_ari_validate_channel_destroyed(), ast_ari_validate_channel_dialplan(), ast_ari_validate_channel_dtmf_received(), ast_ari_validate_channel_entered_bridge(), ast_ari_validate_channel_hangup_request(), ast_ari_validate_channel_hold(), ast_ari_validate_channel_left_bridge(), ast_ari_validate_channel_state_change(), ast_ari_validate_channel_talking_finished(), ast_ari_validate_channel_talking_started(), ast_ari_validate_channel_unhold(), ast_ari_validate_channel_userevent(), ast_ari_validate_channel_varset(), ast_ari_validate_config_info(), ast_ari_validate_config_tuple(), ast_ari_validate_contact_info(), ast_ari_validate_contact_status_change(), ast_ari_validate_device_state(), ast_ari_validate_device_state_changed(), ast_ari_validate_dial(), ast_ari_validate_dialed(), ast_ari_validate_dialplan_cep(), ast_ari_validate_endpoint(), ast_ari_validate_endpoint_state_change(), ast_ari_validate_event(), ast_ari_validate_format_lang_pair(), ast_ari_validate_live_recording(), ast_ari_validate_log_channel(), ast_ari_validate_mailbox(), ast_ari_validate_message(), ast_ari_validate_missing_params(), ast_ari_validate_module(), ast_ari_validate_peer(), ast_ari_validate_peer_status_change(), ast_ari_validate_playback(), ast_ari_validate_playback_continuing(), ast_ari_validate_playback_finished(), ast_ari_validate_playback_started(), ast_ari_validate_recording_failed(), ast_ari_validate_recording_finished(), ast_ari_validate_recording_started(), ast_ari_validate_rtpstat(), ast_ari_validate_set_id(), ast_ari_validate_sound(), ast_ari_validate_stasis_end(), ast_ari_validate_stasis_start(), ast_ari_validate_status_info(), ast_ari_validate_stored_recording(), ast_ari_validate_system_info(), ast_ari_validate_text_message(), ast_ari_validate_text_message_received(), ast_ari_validate_variable(), and ast_json_to_ast_variables().
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.
Iterating forward from this iterator may not to cover all elements in object.
object | JSON object to iterate. |
key | Key of field to lookup. |
NULL | if key does not exist. on error. |
const char* ast_json_object_iter_key | ( | struct ast_json_iter * | iter | ) |
Get the key from an iterator.
iter | JSON object iterator. |
Definition at line 451 of file json.c.
Referenced by ast_ari_validate_application(), ast_ari_validate_application_move_failed(), ast_ari_validate_application_replaced(), ast_ari_validate_asterisk_info(), ast_ari_validate_asterisk_ping(), ast_ari_validate_bridge(), ast_ari_validate_bridge_attended_transfer(), ast_ari_validate_bridge_blind_transfer(), ast_ari_validate_bridge_created(), ast_ari_validate_bridge_destroyed(), ast_ari_validate_bridge_merged(), ast_ari_validate_bridge_video_source_changed(), ast_ari_validate_build_info(), ast_ari_validate_caller_id(), ast_ari_validate_channel(), ast_ari_validate_channel_caller_id(), ast_ari_validate_channel_connected_line(), ast_ari_validate_channel_created(), ast_ari_validate_channel_destroyed(), ast_ari_validate_channel_dialplan(), ast_ari_validate_channel_dtmf_received(), ast_ari_validate_channel_entered_bridge(), ast_ari_validate_channel_hangup_request(), ast_ari_validate_channel_hold(), ast_ari_validate_channel_left_bridge(), ast_ari_validate_channel_state_change(), ast_ari_validate_channel_talking_finished(), ast_ari_validate_channel_talking_started(), ast_ari_validate_channel_unhold(), ast_ari_validate_channel_userevent(), ast_ari_validate_channel_varset(), ast_ari_validate_config_info(), ast_ari_validate_config_tuple(), ast_ari_validate_contact_info(), ast_ari_validate_contact_status_change(), ast_ari_validate_device_state(), ast_ari_validate_device_state_changed(), ast_ari_validate_dial(), ast_ari_validate_dialed(), ast_ari_validate_dialplan_cep(), ast_ari_validate_endpoint(), ast_ari_validate_endpoint_state_change(), ast_ari_validate_event(), ast_ari_validate_format_lang_pair(), ast_ari_validate_live_recording(), ast_ari_validate_log_channel(), ast_ari_validate_mailbox(), ast_ari_validate_message(), ast_ari_validate_missing_params(), ast_ari_validate_module(), ast_ari_validate_peer(), ast_ari_validate_peer_status_change(), ast_ari_validate_playback(), ast_ari_validate_playback_continuing(), ast_ari_validate_playback_finished(), ast_ari_validate_playback_started(), ast_ari_validate_recording_failed(), ast_ari_validate_recording_finished(), ast_ari_validate_recording_started(), ast_ari_validate_rtpstat(), ast_ari_validate_set_id(), ast_ari_validate_sound(), ast_ari_validate_stasis_end(), ast_ari_validate_stasis_start(), ast_ari_validate_status_info(), ast_ari_validate_stored_recording(), ast_ari_validate_system_info(), ast_ari_validate_text_message(), ast_ari_validate_text_message_received(), ast_ari_validate_variable(), and ast_json_to_ast_variables().
struct ast_json_iter* ast_json_object_iter_next | ( | struct ast_json * | object, |
struct ast_json_iter * | iter | ||
) |
Get the next iterator.
object | JSON object iter was obtained from. |
iter | JSON object iterator. |
NULL | if iter was the last field. |
Definition at line 447 of file json.c.
Referenced by ast_ari_validate_application(), ast_ari_validate_application_move_failed(), ast_ari_validate_application_replaced(), ast_ari_validate_asterisk_info(), ast_ari_validate_asterisk_ping(), ast_ari_validate_bridge(), ast_ari_validate_bridge_attended_transfer(), ast_ari_validate_bridge_blind_transfer(), ast_ari_validate_bridge_created(), ast_ari_validate_bridge_destroyed(), ast_ari_validate_bridge_merged(), ast_ari_validate_bridge_video_source_changed(), ast_ari_validate_build_info(), ast_ari_validate_caller_id(), ast_ari_validate_channel(), ast_ari_validate_channel_caller_id(), ast_ari_validate_channel_connected_line(), ast_ari_validate_channel_created(), ast_ari_validate_channel_destroyed(), ast_ari_validate_channel_dialplan(), ast_ari_validate_channel_dtmf_received(), ast_ari_validate_channel_entered_bridge(), ast_ari_validate_channel_hangup_request(), ast_ari_validate_channel_hold(), ast_ari_validate_channel_left_bridge(), ast_ari_validate_channel_state_change(), ast_ari_validate_channel_talking_finished(), ast_ari_validate_channel_talking_started(), ast_ari_validate_channel_unhold(), ast_ari_validate_channel_userevent(), ast_ari_validate_channel_varset(), ast_ari_validate_config_info(), ast_ari_validate_config_tuple(), ast_ari_validate_contact_info(), ast_ari_validate_contact_status_change(), ast_ari_validate_device_state(), ast_ari_validate_device_state_changed(), ast_ari_validate_dial(), ast_ari_validate_dialed(), ast_ari_validate_dialplan_cep(), ast_ari_validate_endpoint(), ast_ari_validate_endpoint_state_change(), ast_ari_validate_event(), ast_ari_validate_format_lang_pair(), ast_ari_validate_live_recording(), ast_ari_validate_log_channel(), ast_ari_validate_mailbox(), ast_ari_validate_message(), ast_ari_validate_missing_params(), ast_ari_validate_module(), ast_ari_validate_peer(), ast_ari_validate_peer_status_change(), ast_ari_validate_playback(), ast_ari_validate_playback_continuing(), ast_ari_validate_playback_finished(), ast_ari_validate_playback_started(), ast_ari_validate_recording_failed(), ast_ari_validate_recording_finished(), ast_ari_validate_recording_started(), ast_ari_validate_rtpstat(), ast_ari_validate_set_id(), ast_ari_validate_sound(), ast_ari_validate_stasis_end(), ast_ari_validate_stasis_start(), ast_ari_validate_status_info(), ast_ari_validate_stored_recording(), ast_ari_validate_system_info(), ast_ari_validate_text_message(), ast_ari_validate_text_message_received(), ast_ari_validate_variable(), and ast_json_to_ast_variables().
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.
value
reference even if it returns error; use ast_json_ref() to safely keep a pointer to it.object | JSON object iter was obtained from. |
iter | JSON object iterator. |
value | JSON value to store in iter's field. |
0 | on success. |
-1 | on error. |
struct ast_json* ast_json_object_iter_value | ( | struct ast_json_iter * | iter | ) |
Get the value from an iterator.
The returned element is a borrowed reference; use ast_json_ref() to safely keep a pointer to it.
iter | JSON object iterator. |
Definition at line 455 of file json.c.
Referenced by ast_ari_validate_application(), ast_ari_validate_application_move_failed(), ast_ari_validate_application_replaced(), ast_ari_validate_asterisk_info(), ast_ari_validate_asterisk_ping(), ast_ari_validate_bridge(), ast_ari_validate_bridge_attended_transfer(), ast_ari_validate_bridge_blind_transfer(), ast_ari_validate_bridge_created(), ast_ari_validate_bridge_destroyed(), ast_ari_validate_bridge_merged(), ast_ari_validate_bridge_video_source_changed(), ast_ari_validate_build_info(), ast_ari_validate_caller_id(), ast_ari_validate_channel(), ast_ari_validate_channel_caller_id(), ast_ari_validate_channel_connected_line(), ast_ari_validate_channel_created(), ast_ari_validate_channel_destroyed(), ast_ari_validate_channel_dialplan(), ast_ari_validate_channel_dtmf_received(), ast_ari_validate_channel_entered_bridge(), ast_ari_validate_channel_hangup_request(), ast_ari_validate_channel_hold(), ast_ari_validate_channel_left_bridge(), ast_ari_validate_channel_state_change(), ast_ari_validate_channel_talking_finished(), ast_ari_validate_channel_talking_started(), ast_ari_validate_channel_unhold(), ast_ari_validate_channel_userevent(), ast_ari_validate_channel_varset(), ast_ari_validate_config_info(), ast_ari_validate_config_tuple(), ast_ari_validate_contact_info(), ast_ari_validate_contact_status_change(), ast_ari_validate_device_state(), ast_ari_validate_device_state_changed(), ast_ari_validate_dial(), ast_ari_validate_dialplan_cep(), ast_ari_validate_endpoint(), ast_ari_validate_endpoint_state_change(), ast_ari_validate_event(), ast_ari_validate_format_lang_pair(), ast_ari_validate_live_recording(), ast_ari_validate_log_channel(), ast_ari_validate_mailbox(), ast_ari_validate_message(), ast_ari_validate_missing_params(), ast_ari_validate_module(), ast_ari_validate_peer(), ast_ari_validate_peer_status_change(), ast_ari_validate_playback(), ast_ari_validate_playback_continuing(), ast_ari_validate_playback_finished(), ast_ari_validate_playback_started(), ast_ari_validate_recording_failed(), ast_ari_validate_recording_finished(), ast_ari_validate_recording_started(), ast_ari_validate_rtpstat(), ast_ari_validate_set_id(), ast_ari_validate_sound(), ast_ari_validate_stasis_end(), ast_ari_validate_stasis_start(), ast_ari_validate_status_info(), ast_ari_validate_stored_recording(), ast_ari_validate_system_info(), ast_ari_validate_text_message(), ast_ari_validate_text_message_received(), ast_ari_validate_variable(), and ast_json_to_ast_variables().
Set a field in a JSON object.
object | JSON object to modify. |
key | Key of field to set. |
value | JSON value to set for field. |
0 | on success. |
-1 | on error. |
Definition at line 414 of file json.c.
Referenced by app_send(), ast_ari_asterisk_get_info(), ast_bridge_snapshot_to_json(), ast_bucket_file_json(), ast_bucket_json(), ast_channel_snapshot_to_json(), ast_endpoint_snapshot_to_json(), ast_json_channel_vars(), ast_json_object_create_vars(), ast_rtp_convert_stats_json(), ast_sorcery_objectset_json_create(), identify_module(), stasis_app_event_filter_to_json(), stasis_app_message_handler(), stasis_app_recording_to_json(), and stasis_app_user_event().
size_t ast_json_object_size | ( | struct ast_json * | object | ) |
Update object with all of the fields of other.
All of the fields of other are copied into object, overwriting existing keys. The other object is not changed, so ast_json_unref() it when you are done with it.
object | JSON object to modify. |
other | JSON object to copy into object. |
0 | on success. |
-1 | on error. |
Update existing fields in object with the fields of other.
Like ast_json_object_update(), but only existing fields are updated. No new fields will get added. The other object is not changed, so ast_json_unref() it when you are done with it.
object | JSON object to modify. |
other | JSON object to copy into object. |
0 | on success. |
-1 | on error. |
Add new fields to object with the fields of other.
Like ast_json_object_update(), but only missing fields are added. No existing fields will be modified. The other object is not changed, so ast_json_unref() it when you are done with it.
object | JSON object to modify. |
other | JSON object to copy into object. |
0 | on success. |
-1 | on error. |
struct ast_json* ast_json_pack | ( | char const * | format, |
... | |||
) |
Helper for creating complex JSON values.
See original Jansson docs at http://www.digip.org/jansson/doc/2.11/apiref.html#apiref-pack for more details.
Definition at line 612 of file json.c.
References ast_json_vpack().
Referenced by add_format_information_cb(), app_send_end_msg(), app_to_json(), app_update(), ast_ari_asterisk_get_global_var(), ast_ari_asterisk_get_info(), ast_ari_asterisk_ping(), ast_ari_channels_get_channel_var(), ast_ari_response_error(), ast_bridge_channel_write_hold(), ast_bridge_publish_enter(), ast_bridge_snapshot_to_json(), ast_cel_publish_event(), ast_cel_publish_user_event(), ast_channel_move(), ast_channel_publish_varset(), ast_channel_snapshot_to_json(), ast_endpoint_snapshot_to_json(), ast_json_dialplan_cep_app(), ast_json_name_number(), ast_json_party_id(), ast_manager_publish_event(), ast_queue_hangup_with_cause(), ast_queue_hold(), ast_rtcp_interpret(), ast_softhangup(), ast_system_publish_registry(), cel_channel_state_change(), confbridge_handle_atxfer(), create_sound_blob(), leave_queue(), local_optimization_finished_cb(), local_optimization_started_cb(), manager_mute_mixmonitor(), process_log_list(), process_module_list(), publish_cluster_discovery_to_stasis_full(), publish_dahdichannel(), publish_load_message_type(), really_quit(), record_abandoned(), report_fax_status(), report_receive_fax_status(), report_send_fax_status(), reset_user_pw(), ring_entry(), rna(), send_agent_complete(), stasis_app_device_state_to_json(), stasis_app_exec(), stasis_app_playback_to_json(), stasis_app_recording_to_json(), stasis_app_user_event(), and update_registry().
struct ast_json* ast_json_party_id | ( | struct ast_party_id * | party | ) |
Construct an ast_party_id as JSON.
party | The party ID to represent as JSON. |
name
, number
and subaddress
objects for those that are valid in the party ID Definition at line 805 of file json.c.
References ast_describe_caller_presentation(), ast_json_pack(), ast_party_id_presentation(), ast_party_id::name, ast_party_id::number, and ast_party_id::subaddress.
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.
json | the ast_json blob we are loading |
NULL | if we fail to alloc it |
Definition at line 756 of file json.c.
References ast_json_ref().
Referenced by ast_manager_publish_event(), ast_system_publish_registry(), publish_cluster_discovery_to_stasis_full(), publish_load_message_type(), and stun_monitor_request().
struct ast_json* ast_json_real_create | ( | double | value | ) |
Create a JSON real number.
value | Value of the new JSON real number. |
NULL | on error. |
Definition at line 342 of file json.c.
Referenced by ast_ari_asterisk_get_info(), and ast_rtp_convert_stats_json().
double ast_json_real_get | ( | const struct ast_json * | real | ) |
int ast_json_real_set | ( | struct ast_json * | real, |
double | value | ||
) |
Increase refcount on value.
value | JSON value to reference. |
Definition at line 67 of file json.c.
Referenced by ari_bridges_play_found(), ast_ari_applications_list(), ast_ari_applications_subscribe(), ast_ari_applications_unsubscribe(), ast_ari_asterisk_get_global_var(), ast_ari_asterisk_get_info(), ast_ari_bridges_list(), ast_ari_bridges_record(), ast_ari_channels_get_channel_var(), ast_ari_channels_list(), ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_ari_recordings_list_stored(), ast_ari_response_alloc_failed(), ast_ari_response_error(), ast_ari_websocket_session_read(), ast_bridge_blob_create(), ast_bridge_blob_create_from_snapshots(), ast_bucket_file_json(), ast_bucket_json(), ast_cel_publish_event(), ast_endpoint_blob_create(), ast_json_payload_create(), ast_manager_publish_event(), ast_multi_channel_blob_create(), ast_multi_object_blob_create(), ast_mwi_blob_create(), ast_rtp_publish_rtcp_message(), create_sound_blob(), publish_load_message_type(), report_receive_fax_status(), stasis_app_event_filter_to_json(), stasis_app_message_handler(), stasis_app_playback_to_json(), stasis_app_recording_to_json(), and stasis_app_user_event().
void ast_json_reset_alloc_funcs | ( | void | ) |
Change alloc funcs back to the resource module defaults.
If you use ast_json_set_alloc_funcs() to temporarily change the allocator functions (i.e., from in a unit test), this function sets them back to ast_malloc() and ast_free().
Definition at line 62 of file json.c.
References ast_json_free(), and ast_json_malloc().
Referenced by ast_json_init().
void ast_json_set_alloc_funcs | ( | void *(*)(size_t) | malloc_fn, |
void(*)(void *) | free_fn | ||
) |
Set custom allocators instead of the standard ast_malloc() and ast_free().
This is used by the unit tests to do JSON specific memory leak detection. Since it affects all users of the JSON library, shouldn't normally be used.
malloc_fn | Custom allocation function. |
free_fn | Matching free function. |
struct ast_json* ast_json_string_create | ( | const char * | value | ) |
Construct a JSON string from value.
The given value must be a valid ASCII or UTF-8 encoded string.
value | Value of new JSON string. |
NULL | on error. |
Definition at line 278 of file json.c.
Referenced by app_send(), app_to_json(), ast_bridge_snapshot_to_json(), ast_bucket_file_json(), ast_bucket_json(), ast_channel_snapshot_to_json(), ast_endpoint_snapshot_to_json(), ast_json_channel_vars(), ast_json_ipaddr(), ast_json_object_create_vars(), ast_json_timeval(), ast_rtp_convert_stats_json(), ast_sorcery_objectset_json_create(), identify_module(), report_receive_fax_status(), stasis_app_exec(), stasis_app_message_handler(), and stasis_app_user_event().
const char* ast_json_string_get | ( | const struct ast_json * | string | ) |
Get the value of a JSON string.
string | JSON string. |
NULL | on error. |
Definition at line 283 of file json.c.
Referenced by app_send(), ast_ari_applications_subscribe_parse_body(), ast_ari_applications_unsubscribe_parse_body(), ast_ari_asterisk_add_log_parse_body(), ast_ari_asterisk_get_global_var_parse_body(), ast_ari_asterisk_get_info_parse_body(), ast_ari_asterisk_set_global_var_parse_body(), ast_ari_asterisk_update_object(), ast_ari_bridges_add_channel_parse_body(), ast_ari_bridges_create_parse_body(), ast_ari_bridges_create_with_id_parse_body(), ast_ari_bridges_play_parse_body(), ast_ari_bridges_play_with_id_parse_body(), ast_ari_bridges_record_parse_body(), ast_ari_bridges_remove_channel_parse_body(), ast_ari_bridges_start_moh_parse_body(), ast_ari_channels_continue_in_dialplan_parse_body(), ast_ari_channels_create_parse_body(), ast_ari_channels_dial_parse_body(), ast_ari_channels_external_media_parse_body(), ast_ari_channels_get_channel_var_parse_body(), ast_ari_channels_hangup_parse_body(), ast_ari_channels_move_parse_body(), ast_ari_channels_mute_parse_body(), ast_ari_channels_originate_parse_body(), ast_ari_channels_originate_with_id_parse_body(), ast_ari_channels_play_parse_body(), ast_ari_channels_play_with_id_parse_body(), ast_ari_channels_record_parse_body(), ast_ari_channels_redirect_parse_body(), ast_ari_channels_send_dtmf_parse_body(), ast_ari_channels_set_channel_var_parse_body(), ast_ari_channels_snoop_channel_parse_body(), ast_ari_channels_snoop_channel_with_id_parse_body(), ast_ari_channels_start_moh_parse_body(), ast_ari_channels_unmute_parse_body(), ast_ari_device_states_update_parse_body(), ast_ari_endpoints_refer_parse_body(), ast_ari_endpoints_refer_to_endpoint_parse_body(), ast_ari_endpoints_send_message_parse_body(), ast_ari_endpoints_send_message_to_endpoint_parse_body(), ast_ari_events_user_event_parse_body(), ast_ari_playbacks_control_parse_body(), ast_ari_recordings_copy_stored_parse_body(), ast_ari_sounds_list_parse_body(), ast_ari_validate_date(), ast_ari_validate_event(), ast_ari_validate_message(), ast_json_to_ast_variables(), channel_dial_cb(), handle_dial_message(), mwi_app_event_cb(), and stasis_app_message_handler().
int ast_json_string_set | ( | struct ast_json * | string, |
const char * | value | ||
) |
Change the value of a JSON string.
The given value must be a valid ASCII or UTF-8 encoded string.
string | JSON string to modify. |
value | New value to store in string. |
0 | on success. |
-1 | on error. |
Definition at line 288 of file json.c.
Referenced by conf_send_event_to_participants().
struct ast_json* ast_json_stringf | ( | const char * | format, |
... | |||
) |
Create a JSON string, printf style.
The formatted value must be a valid ASCII or UTF-8 encoded string.
format | printf style format string. |
NULL | on error. |
Definition at line 293 of file json.c.
References ast_json_vstringf().
struct ast_json* ast_json_timeval | ( | const struct timeval | tv, |
const char * | zone | ||
) |
Construct a timeval as JSON.
JSON does not define a standard date format (boo), but the de facto standard is to use ISO 8601 formatted string. We build a millisecond resolution string from the timeval
tv | timeval to encode. |
zone | Text string of a standard system zoneinfo file. If NULL, the system localtime will be used. |
NULL | on error. |
Definition at line 670 of file json.c.
References AST_ISO8601_FORMAT, AST_ISO8601_LEN, ast_json_string_create(), ast_localtime(), and ast_strftime().
Referenced by app_send_end_msg(), app_update(), ast_ari_asterisk_get_info(), ast_ari_asterisk_ping(), ast_bridge_snapshot_to_json(), ast_channel_snapshot_to_json(), and stasis_app_exec().
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.
json_variables | The JSON blob containing the variable |
variables | An out reference to the variables to populate. |
Definition at line 818 of file json.c.
References ast_json_object_iter(), ast_json_object_iter_key(), ast_json_object_iter_next(), ast_json_object_iter_value(), ast_json_string_get(), AST_JSON_TO_AST_VARS_CODE_INVALID_TYPE, AST_JSON_TO_AST_VARS_CODE_OOM, AST_JSON_TO_AST_VARS_CODE_SUCCESS, ast_json_typeof(), ast_variable_list_append_hint(), ast_variables_destroy(), and ast_variable::value.
Referenced by sorcery_astdb_retrieve_fields_common().
struct ast_json* ast_json_true | ( | void | ) |
Get the JSON true value.
The returned value is a singleton, and does not need to be ast_json_unref()'ed.
const char* ast_json_typename | ( | enum ast_json_type | type | ) |
Get the string name for the given type.
type | Type to convert to string. |
? | for invalid types. |
Definition at line 95 of file json.c.
Referenced by ast_ari_validate_boolean().
enum ast_json_type ast_json_typeof | ( | const struct ast_json * | value | ) |
Get the type of value.
value | Value to query. |
Definition at line 78 of file json.c.
Referenced by ast_ari_applications_subscribe_parse_body(), ast_ari_applications_unsubscribe_parse_body(), ast_ari_asterisk_get_info_parse_body(), ast_ari_bridges_add_channel_parse_body(), ast_ari_bridges_play_parse_body(), ast_ari_bridges_play_with_id_parse_body(), ast_ari_bridges_remove_channel_parse_body(), ast_ari_channels_play_parse_body(), ast_ari_channels_play_with_id_parse_body(), ast_ari_events_user_event_parse_body(), ast_ari_validate_boolean(), and ast_json_to_ast_variables().
void ast_json_unref | ( | struct ast_json * | value | ) |
Decrease refcount on value. If refcount reaches zero, value is freed.
NULL
to this function. Definition at line 73 of file json.c.
Referenced by app_send_end_msg(), app_to_json(), app_update(), ari_bridges_play_found(), ast_aoc_manager_event(), ast_ari_applications_list(), ast_ari_applications_subscribe(), ast_ari_applications_unsubscribe(), ast_ari_asterisk_get_global_var(), ast_ari_asterisk_get_info(), ast_ari_asterisk_get_module(), ast_ari_asterisk_list_log_channels(), ast_ari_bridges_list(), ast_ari_bridges_record(), ast_ari_channels_get_channel_var(), ast_ari_channels_list(), ast_ari_endpoints_list(), ast_ari_endpoints_list_by_tech(), ast_ari_recordings_list_stored(), ast_ari_response_error(), ast_ari_sounds_list(), ast_ari_websocket_events_event_websocket_established(), ast_ari_websocket_session_read(), ast_bridge_channel_write_hold(), ast_bridge_publish_enter(), ast_bucket_file_json(), ast_bucket_json(), ast_cel_publish_event(), ast_cel_publish_user_event(), ast_channel_move(), ast_channel_publish_varset(), ast_endpoint_snapshot_to_json(), ast_manager_publish_event(), ast_queue_hangup_with_cause(), ast_queue_hold(), ast_rtcp_interpret(), ast_rtp_convert_stats_json(), ast_softhangup(), ast_sorcery_objectset_json_create(), ast_system_publish_registry(), cel_channel_state_change(), conf_send_event_to_participants(), confbridge_handle_atxfer(), create_sound_blob(), event_session_shutdown(), event_session_update_websocket(), leave_queue(), local_optimization_finished_cb(), local_optimization_started_cb(), manager_mute_mixmonitor(), publish_cluster_discovery_to_stasis_full(), publish_dahdichannel(), publish_load_message_type(), really_quit(), record_abandoned(), report_fax_status(), report_receive_fax_status(), report_send_fax_status(), reset_user_pw(), ring_entry(), rna(), send_agent_complete(), sorcery_astdb_retrieve_fields_common(), stasis_app_exec(), stasis_app_mailboxes_to_json(), stasis_app_playback_to_json(), stasis_app_recording_to_json(), stasis_app_user_event(), stun_monitor_request(), and update_registry().
int ast_json_utf8_check | ( | const char * | str | ) |
Check the nul terminated string for UTF-8 format.
str | String to check. |
0 | if not UTF-8 encoded or str is NULL. |
1 | if UTF-8 encoded. |
Definition at line 228 of file json.c.
References ast_json_utf8_check_len().
int ast_json_utf8_check_len | ( | const char * | str, |
size_t | len | ||
) |
Check the string of the given length for UTF-8 format.
str | String to check. |
len | Length of string to check. |
0 | if not UTF-8 encoded or str is NULL. |
1 | if UTF-8 encoded. |
Definition at line 186 of file json.c.
References ast_debug.
Referenced by ast_json_utf8_check().
struct ast_json* ast_json_vpack | ( | char const * | format, |
va_list | ap | ||
) |
Helper for creating complex JSON values simply.
See original Jansson docs at http://www.digip.org/jansson/doc/2.11/apiref.html#apiref-pack for more details.
Definition at line 621 of file json.c.
References ast_log_backtrace().
Referenced by ast_json_pack().
struct ast_json* ast_json_vstringf | ( | const char * | format, |
va_list | args | ||
) |
Create a JSON string, vprintf style.
The formatted value must be a valid ASCII or UTF-8 encoded string.
format | printf style format string. |
args |
NULL | on error. |
Definition at line 303 of file json.c.
References ast_vasprintf.
Referenced by ast_ari_response_error(), and ast_json_stringf().