json: Take advantage of new API's.

* Use "o*" format specifier for optional fields in ast_json_party_id.
* Stop using ast_json_deep_copy on immutable objects, it is now thread
  safe to just use ast_json_ref.

Additional changes to ast_json_pack calls in the vicinity:
* Use "O" when an object needs to be bumped.  This was previously
  avoided as it was not thread safe.
* Use "o?" and "O?" to replace NULL with ast_json_null().  The
  "?" is a new feature of ast_json_pack starting with Asterisk 16.

Change-Id: I8382d28d7d83ee0ce13334e51ae45dbc0bdaef48
This commit is contained in:
Corey Farrell
2018-07-16 23:55:02 -04:00
parent 6e1cf9de6b
commit 93777faf36
6 changed files with 19 additions and 41 deletions

View File

@@ -1368,8 +1368,8 @@ static struct ast_json *multi_user_event_to_json(
ast_json_object_set(out, "type", ast_json_string_create("ChannelUserevent"));
ast_json_object_set(out, "timestamp", ast_json_timeval(*tv, NULL));
ast_json_object_set(out, "eventname", ast_json_string_create(ast_json_string_get((ast_json_object_get(blob, "eventname")))));
ast_json_object_set(out, "userevent", ast_json_deep_copy(blob));
ast_json_object_set(out, "eventname", ast_json_ref(ast_json_object_get(blob, "eventname")));
ast_json_object_set(out, "userevent", ast_json_ref(blob));
for (type = 0; type < STASIS_UMOS_MAX; ++type) {
for (i = 0; i < AST_VECTOR_SIZE(&multi->snapshots[type]); ++i) {