aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-wsj1.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2018-07-24 11:47:44 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2018-07-24 16:28:32 +0200
commit77ca8b40f2d0c8b1cbf9960bd5a5b2aec36fef38 (patch)
tree90a0206c748dde157460dce3524bf88f49552ed6 /src/afb-wsj1.c
parente17ae412245ba9afb33ff6a0f1f665b4d66d4da4 (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-wsj1.c')
-rw-r--r--src/afb-wsj1.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/afb-wsj1.c b/src/afb-wsj1.c
index 466b58ad..f2b4a084 100644
--- a/src/afb-wsj1.c
+++ b/src/afb-wsj1.c
@@ -26,6 +26,9 @@
#include <pthread.h>
#include <json-c/json.h>
+#if !defined(JSON_C_TO_STRING_NOSLASHESCAPE)
+#define JSON_C_TO_STRING_NOSLASHESCAPE 0
+#endif
#include "afb-ws.h"
#include "afb-wsj1.h"
@@ -473,7 +476,7 @@ static int wsj1_send_issot(struct afb_wsj1 *wsj1, int i1, const char *s1, const
int afb_wsj1_send_event_j(struct afb_wsj1 *wsj1, const char *event, struct json_object *object)
{
- const char *objstr = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN);
+ const char *objstr = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE);
int rc = afb_wsj1_send_event_s(wsj1, event, objstr);
json_object_put(object);
return rc;
@@ -486,7 +489,7 @@ int afb_wsj1_send_event_s(struct afb_wsj1 *wsj1, const char *event, const char *
int afb_wsj1_call_j(struct afb_wsj1 *wsj1, const char *api, const char *verb, struct json_object *object, void (*on_reply)(void *closure, struct afb_wsj1_msg *msg), void *closure)
{
- const char *objstr = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN);
+ const char *objstr = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE);
int rc = afb_wsj1_call_s(wsj1, api, verb, objstr, on_reply, closure);
json_object_put(object);
return rc;
@@ -520,7 +523,7 @@ int afb_wsj1_call_s(struct afb_wsj1 *wsj1, const char *api, const char *verb, co
int afb_wsj1_reply_j(struct afb_wsj1_msg *msg, struct json_object *object, const char *token, int iserror)
{
- const char *objstr = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN);
+ const char *objstr = json_object_to_json_string_ext(object, JSON_C_TO_STRING_PLAIN|JSON_C_TO_STRING_NOSLASHESCAPE);
int rc = afb_wsj1_reply_s(msg, objstr, token, iserror);
json_object_put(object);
return rc;