diff options
author | José Bollo <jose.bollo@iot.bzh> | 2018-07-24 11:47:44 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2018-07-24 16:28:32 +0200 |
commit | 77ca8b40f2d0c8b1cbf9960bd5a5b2aec36fef38 (patch) | |
tree | 90a0206c748dde157460dce3524bf88f49552ed6 /src/afb-api-dbus.c | |
parent | e17ae412245ba9afb33ff6a0f1f665b4d66d4da4 (diff) |
json-c: Remove escaping of slashs
By default json-c escapes the slashes. This is almost ugly
and unuseful. But the resolution (with JSON_C_TO_STRING_NOSLASHESCAPE)
was introduced lately by json-c. Integrate it as much as possible.
Change-Id: Ia9c4bee78dc11df1ee9640cb04311991bd860e43
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-api-dbus.c')
-rw-r--r-- | src/afb-api-dbus.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/afb-api-dbus.c b/src/afb-api-dbus.c index a2c9b086..227658f4 100644 --- a/src/afb-api-dbus.c +++ b/src/afb-api-dbus.c @@ -27,6 +27,9 @@ #include <systemd/sd-bus.h> #include <json-c/json.h> +#if !defined(JSON_C_TO_STRING_NOSLASHESCAPE) +#define JSON_C_TO_STRING_NOSLASHESCAPE 0 +#endif #include <afb/afb-event-x2.h> @@ -43,6 +46,7 @@ #include "afb-xreq.h" #include "verbose.h" + static const char DEFAULT_PATH_PREFIX[] = "/org/agl/afb/api/"; struct dbus_memo; @@ -810,7 +814,7 @@ void dbus_req_raw_reply(struct afb_xreq *xreq, struct json_object *obj, const ch int rc; rc = sd_bus_reply_method_return(dreq->message, "sss", - obj ? json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN) : "", + obj ? json_object_to_json_string_ext(obj, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE) : "", error ? : "", info ? : ""); if (rc < 0) @@ -892,7 +896,7 @@ static void afb_api_dbus_server_event_remove(void *closure, const char *event, i static void afb_api_dbus_server_event_push(void *closure, const char *event, int eventid, struct json_object *object) { - const char *data = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN); + const char *data = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE); afb_api_dbus_server_event_send(closure, '!', event, eventid, data, 0); json_object_put(object); } @@ -904,7 +908,7 @@ static void afb_api_dbus_server_event_broadcast(void *closure, const char *event api = closure; rc = sd_bus_emit_signal(api->sdbus, api->path, api->name, "broadcast", - "ss", event, json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN)); + "ss", event, json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE)); if (rc < 0) ERROR("error while broadcasting event %s", event); json_object_put(object); |