mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 03:20:57 +00:00
strings/json: Add string delimter match, and object create with vars methods
Add a function to check if there is an exact match a one string between delimiters in another string. Add a function that will create an ast_json object out of a list of Asterisk variables. An excludes string can also optionally be passed in. Also, add a macro to make it easier to get object integers. Change-Id: I5f34f18e102126aef3997f19a553a266d70d6226
This commit is contained in:
committed by
George Joseph
parent
1031a1805b
commit
67d1f881eb
19
main/json.c
19
main/json.c
@@ -852,3 +852,22 @@ struct ast_json *ast_json_channel_vars(struct varshead *channelvars)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct ast_json *ast_json_object_create_vars(const struct ast_variable *variables, const char *excludes)
|
||||
{
|
||||
const struct ast_variable *i;
|
||||
struct ast_json *obj;
|
||||
|
||||
obj = ast_json_object_create();
|
||||
if (!obj) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (i = variables; i; i = i->next) {
|
||||
if (!excludes || !ast_in_delimited_string(i->name, excludes, ',')) {
|
||||
ast_json_object_set(obj, i->name, ast_json_string_create(i->value));
|
||||
}
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
Reference in New Issue
Block a user