diff --git a/src/ext/handlersToJson.c b/src/ext/handlersToJson.c index c655edb..04a0e48 100644 --- a/src/ext/handlersToJson.c +++ b/src/ext/handlersToJson.c @@ -153,7 +153,7 @@ static RdbRes toJsonDbSize(RdbParser *p, void *userData, uint64_t db_size, uint6 } /* output json part */ - fprintf(ctx->outfile, " \"__dbsize__\": {\n"); + fprintf(ctx->outfile, " \"%sdbsize__\": {\n", jsonMetaPrefix); /* group dbsize with {..} */ fprintf(ctx->outfile, " \"size\": %" PRIu64 ",\n", db_size); fprintf(ctx->outfile, " \"expires\": %" PRIu64 "\n", exp_size); fprintf(ctx->outfile, " }%s\n", (db_size) ? "," : ""); @@ -171,7 +171,7 @@ static RdbRes toJsonSlotInfo(RdbParser *p, void *userData, RdbSlotInfo *info) { } /* output json part */ - fprintf(ctx->outfile, " \"__slotinfo__\": {\n"); + fprintf(ctx->outfile, " \"%sslotinfo__\": {\n", jsonMetaPrefix); fprintf(ctx->outfile, " \"slotId\": %lu,\n", info->slot_id); fprintf(ctx->outfile, " \"slotSize\": %lu,\n", info->slot_size); fprintf(ctx->outfile, " \"slotSExpiresSize\": %lu\n", info->expires_slot_size); @@ -184,7 +184,7 @@ static RdbRes toJsonAuxField(RdbParser *p, void *userData, RdbBulk auxkey, RdbBu if (ctx->state == R2J_IDLE) { ctx->state = R2J_AUX_FIELDS; - fprintf(ctx->outfile, "\"__aux__\" : {\n "); /* group aux-fields with { ... } */ + fprintf(ctx->outfile, " \"%saux__\": {\n", jsonMetaPrefix); /* group aux-fields with {..} */ } else if (ctx->state == R2J_AUX_FIELDS) { fprintf(ctx->outfile, ",\n "); } else { @@ -503,9 +503,9 @@ static RdbRes toJsonFunction(RdbParser *p, void *userData, RdbBulk func) { if (ctx->state == R2J_IDLE) { ctx->state = R2J_FUNCTIONS; - fprintf(ctx->outfile, "\"__func__\": {\n"); + fprintf(ctx->outfile, "\"%sfunc__\": {\n", jsonMetaPrefix); } else if (ctx->state == R2J_AUX_FIELDS) { - fprintf(ctx->outfile, "\n},\n \"__func__\": {\n"); + fprintf(ctx->outfile, "\n},\n \"%sfunc__\": {\n", jsonMetaPrefix); ctx->state = R2J_FUNCTIONS; } else if (ctx->state == R2J_FUNCTIONS) { fprintf(ctx->outfile, ",\n"); diff --git a/test/dumps/plain_hash_data.json b/test/dumps/plain_hash_data.json new file mode 100644 index 0000000..7236adf --- /dev/null +++ b/test/dumps/plain_hash_data.json @@ -0,0 +1,8 @@ +"__aux__" : { + "redis-ver":"3.2.1", + "redis-bits":"64", + "ctime":"1689605183", + "used-mem":"821904" +}, + +"myhash1":{"5":"5","6":"6","10":"10","1":"1","2":"2","8":"8","4":"4","9":"9","3":"3","7":"7","11":"11"} diff --git a/test/dumps/plain_hash_struct.json b/test/dumps/plain_hash_struct.json new file mode 100644 index 0000000..7236adf --- /dev/null +++ b/test/dumps/plain_hash_struct.json @@ -0,0 +1,8 @@ +"__aux__" : { + "redis-ver":"3.2.1", + "redis-bits":"64", + "ctime":"1689605183", + "used-mem":"821904" +}, + +"myhash1":{"5":"5","6":"6","10":"10","1":"1","2":"2","8":"8","4":"4","9":"9","3":"3","7":"7","11":"11"}