From 1108243f1f5dc44cb3da2f80ccf5c49e2d9968f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Apr 2016 01:16:32 -0500 Subject: [PATCH] test --- iguana/iguana_rpc.c | 3 ++- iguana/main.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index 0be58806b..23df918e8 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -34,7 +34,8 @@ char *sglue(GLUEARGS,char *agent,char *method) { if ( (retjson= cJSON_Parse(retstr)) != 0 ) { - jdelete(retjson,"tag"); + if ( jobj(retjson,"tag") != 0 ) + jdelete(retjson,"tag"); ///printf("RPCret.(%s) n.%d\n",jprint(retjson,0),cJSON_GetArraySize(retjson)); result = cJSON_GetObjectItem(retjson,"result"); error = cJSON_GetObjectItem(retjson,"error"); diff --git a/iguana/main.c b/iguana/main.c index 9932fcfc7..f3ca7a965 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -304,15 +304,19 @@ char *SuperNET_processJSON(struct supernet_info *myinfo,cJSON *json,char *remote { if ( (retjsonstr[0] == '{' || retjsonstr[0] == '[') && (retjson= cJSON_Parse(retjsonstr)) != 0 ) { - if ( j64bits(retjson,"tag") != tag ) + if ( is_cJSON_Array(retjson) == 0 ) { - if ( jobj(retjson,"tag") != 0 ) - jdelete(retjson,"tag"); - jadd64bits(retjson,"tag",tag); + if ( j64bits(retjson,"tag") != tag ) + { + if ( jobj(retjson,"tag") != 0 ) + jdelete(retjson,"tag"); + jadd64bits(retjson,"tag",tag); + } + retstr = jprint(retjson,1); + //printf("retstr.(%s) retjsonstr.%p retjson.%p\n",retstr,retjsonstr,retjson); } - retstr = jprint(retjson,1); - //printf("retstr.(%s) retjsonstr.%p retjson.%p\n",retstr,retjsonstr,retjson); - free(retjsonstr);//,strlen(retjsonstr)+1); + else retstr = retjsonstr; + free(retjsonstr); } else retstr = retjsonstr; } free(jsonstr);