Module: kamailio Branch: master Commit: 5fe86186e2856ce5039c0133e1f53b62df2be485 URL: https://github.com/kamailio/kamailio/commit/5fe86186e2856ce5039c0133e1f53b62...
Author: Emmanuel Schmidbauer emmanuel@getweave.com Committer: Emmanuel Schmidbauer emmanuel@getweave.com Date: 2018-01-29T07:32:11-07:00
json: add get_object API and fix str init
---
Modified: src/modules/json/api.h Modified: src/modules/json/json_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/5fe86186e2856ce5039c0133e1f53b62... Patch: https://github.com/kamailio/kamailio/commit/5fe86186e2856ce5039c0133e1f53b62...
---
diff --git a/src/modules/json/api.h b/src/modules/json/api.h index 80d18c2c25..c900dd5c0d 100644 --- a/src/modules/json/api.h +++ b/src/modules/json/api.h @@ -25,11 +25,12 @@ #include "../../core/sr_module.h"
typedef struct json_object *(*json_parse_f) (const char *str); -typedef str (*json_extract_field_f)( - struct json_object *json_obj, char *json_name); +typedef struct json_object *(*json_get_object_f) (struct json_object *json_obj, const char *str); +typedef str (*json_extract_field_f) (struct json_object *json_obj, char *json_name);
typedef struct json_api { json_parse_f json_parse; + json_get_object_f get_object; json_extract_field_f extract_field; } json_api_t;
diff --git a/src/modules/json/json_mod.c b/src/modules/json/json_mod.c index a008c13085..051da4dd59 100644 --- a/src/modules/json/json_mod.c +++ b/src/modules/json/json_mod.c @@ -65,9 +65,8 @@ struct module_exports exports = { 0 /* per-child init function */ };
-str _json_extract_field(struct json_object *json_obj, char *json_name) -{ - str val; +str _json_extract_field(struct json_object *json_obj, char *json_name) { + str val = {0, 0}; json_extract_field(json_name, val); return val; } @@ -81,6 +80,7 @@ int bind_json(json_api_t *api) { return -1; } api->json_parse = json_parse; + api->get_object = json_get_object; api->extract_field = _json_extract_field; return 0; }