X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-wsj1.c;h=f2b4a0843cc1bb627d281bbe5f7ed9d4bcf7a273;hb=9c2e6e45d4c9745c4702ac1992a0cb086e99fb0b;hp=79cb66e9131c078beec9c202f248f5972332f5fb;hpb=24d000c2290126abf88204089d132229d63f9a05;p=src%2Fapp-framework-binder.git diff --git a/src/afb-wsj1.c b/src/afb-wsj1.c index 79cb66e9..f2b4a084 100644 --- a/src/afb-wsj1.c +++ b/src/afb-wsj1.c @@ -26,6 +26,9 @@ #include #include +#if !defined(JSON_C_TO_STRING_NOSLASHESCAPE) +#define JSON_C_TO_STRING_NOSLASHESCAPE 0 +#endif #include "afb-ws.h" #include "afb-wsj1.h" @@ -392,6 +395,8 @@ struct json_object *afb_wsj1_msg_object_j(struct afb_wsj1_msg *msg) pthread_mutex_lock(&msg->wsj1->mutex); json_tokener_reset(msg->wsj1->tokener); object = json_tokener_parse_ex(msg->wsj1->tokener, msg->object_s, (int)msg->object_s_length); + if (object == NULL && json_tokener_get_error(msg->wsj1->tokener) == json_tokener_continue) + object = json_tokener_parse_ex(msg->wsj1->tokener, "", 1); pthread_mutex_unlock(&msg->wsj1->mutex); if (object == NULL) { /* lazy error detection of json request. Is it to improve? */ @@ -471,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; @@ -484,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; @@ -518,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;