25 #define JSON_MSG(lvalue, rvalue) struct message_json *lvalue = \
26 ((struct message_json *)rvalue)
38 static int message_json_construct1(
struct ast_aeap_message *
self,
const void *params)
44 return msg->json ? 0 : -1;
47 static int message_json_construct2(
struct ast_aeap_message *
self,
const char *msg_type,
48 const char *name,
const char *
id,
const void *params)
53 msg_data =
ast_json_pack(
"{s:s,s:s*}", msg_type, name,
"id",
id);
56 ast_log(LOG_ERROR,
"AEAP message json: failed to create data for '%s: %s'", msg_type, name);
61 ast_log(LOG_ERROR,
"AEAP message json: failed to update data for '%s: %s'", msg_type, name);
66 res = message_json_construct1(
self, msg_data);
78 static int message_json_deserialize(
struct ast_aeap_message *
self,
const void *buf, intmax_t size)
84 return msg->json ? 0 : -1;
87 static int message_json_serialize(
const struct ast_aeap_message *
self,
void **buf, intmax_t *size)
89 const JSON_MSG(msg,
self);
104 const JSON_MSG(msg,
self);
109 static int message_json_id_set(
struct ast_aeap_message *
self,
const char *
id)
122 const JSON_MSG(msg,
self);
142 const JSON_MSG(msg,
self);
149 const JSON_MSG(msg,
self);
154 static const char *message_json_error_msg(
const struct ast_aeap_message *
self)
156 const JSON_MSG(msg,
self);
161 static int message_json_error_msg_set(
struct ast_aeap_message *
self,
const char *error_msg)
175 .serial_type = AST_AEAP_DATA_TYPE_STRING,
176 .construct1 = message_json_construct1,
177 .construct2 = message_json_construct2,
178 .destruct = message_json_destruct,
179 .deserialize = message_json_deserialize,
180 .serialize = message_json_serialize,
181 .id = message_json_id,
182 .id_set = message_json_id_set,
183 .name = message_json_name,
184 .data = message_json_data,
185 .is_request = message_json_is_request,
186 .is_response = message_json_is_response,
187 .error_msg = message_json_error_msg,
188 .error_msg_set = message_json_error_msg_set,
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Asterisk main include file. File version handling, generic pbx functions.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
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.
Asterisk External Application Protocol Message API.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
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.
Asterisk external application JSON message type.
#define ast_json_dump_string(root)
Encode a JSON value to a compact string.
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_aeap_message base
Asterisk JSON abstraction layer.
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.
#define ast_json_object_string_get(object, key)
Get a string field from a JSON object.
const char * ast_json_string_get(const struct ast_json *string)
Get the value of a JSON string.
Asterisk external application base message.
Message type virtual method table.
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
Abstract JSON element (object, array, string, int, ...).
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.
const struct ast_aeap_message_type * ast_aeap_message_type_json
Asterisk external application JSON message type.