From ec4b60bebcab23d46aa09bed06018457c35e5afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Neira=20Ayuso?= Date: Sun, 13 Oct 2013 21:52:34 +0200 Subject: src: json: remove spaces Remove all the spaces from the JSON output to reduce the size of the output string, this also provides a consistent output in table, chain, rule and set. As Stephen Hemminger suggested, better to squash the output to consume as less bytes as possible. Signed-off-by: Alvaro Neira Ayuso Signed-off-by: Pablo Neira Ayuso --- src/chain.c | 24 ++++++++++++------------ src/expr/bitwise.c | 10 +++++----- src/expr/byteorder.c | 10 +++++----- src/expr/cmp.c | 2 +- src/expr/counter.c | 2 +- src/expr/ct.c | 6 +++--- src/expr/data_reg.c | 20 ++++++++++---------- src/expr/exthdr.c | 6 +++--- src/expr/immediate.c | 4 ++-- src/expr/limit.c | 4 ++-- src/expr/log.c | 8 ++++---- src/expr/lookup.c | 2 +- src/expr/match.c | 2 +- src/expr/meta.c | 4 ++-- src/expr/nat.c | 16 +++++++--------- src/expr/payload.c | 8 ++++---- src/expr/target.c | 2 +- src/rule.c | 18 ++++++++---------- src/ruleset.c | 2 +- src/set.c | 16 ++++++++-------- src/set_elem.c | 6 +++--- src/table.c | 8 ++++---- 22 files changed, 88 insertions(+), 92 deletions(-) (limited to 'src') diff --git a/src/chain.c b/src/chain.c index f831479..6179f68 100644 --- a/src/chain.c +++ b/src/chain.c @@ -754,14 +754,14 @@ static int nft_chain_snprintf_json(char *buf, size_t size, struct nft_chain *c) int ret, len = size, offset = 0; ret = snprintf(buf, len, - "{ \"chain\": {" - "\"name\": \"%s\"," - "\"handle\": %"PRIu64"," - "\"bytes\": %"PRIu64"," - "\"packets\": %"PRIu64"," - "\"family\": \"%s\"," - "\"table\": \"%s\"," - "\"use\": %d", + "{\"chain\":{" + "\"name\":\"%s\"," + "\"handle\":%"PRIu64"," + "\"bytes\":%"PRIu64"," + "\"packets\":%"PRIu64"," + "\"family\":\"%s\"," + "\"table\":\"%s\"," + "\"use\":%d", c->name, c->handle, c->bytes, c->packets, nft_family2str(c->family), c->table, c->use); @@ -769,10 +769,10 @@ static int nft_chain_snprintf_json(char *buf, size_t size, struct nft_chain *c) if (c->flags & (1 << NFT_CHAIN_ATTR_HOOKNUM)) { ret = snprintf(buf+offset, len, - ",\"type\": \"%s\"," - "\"hooknum\": \"%s\"," - "\"prio\": %d," - "\"policy\": \"%s\"", + ",\"type\":\"%s\"," + "\"hooknum\":\"%s\"," + "\"prio\":%d," + "\"policy\":\"%s\"", c->type, nft_hooknum2str(c->family, c->hooknum), c->prio, nft_verdict2str(c->policy)); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); diff --git a/src/expr/bitwise.c b/src/expr/bitwise.c index f293069..0be1593 100644 --- a/src/expr/bitwise.c +++ b/src/expr/bitwise.c @@ -283,20 +283,20 @@ nft_rule_expr_bitwise_snprintf_json(char *buf, size_t size, { int len = size, offset = 0, ret; - ret = snprintf(buf, len, "\"sreg\" : %u, " - "\"dreg\" : %u, " - "\"len\" : %u, ", + ret = snprintf(buf, len, "\"sreg\":%u," + "\"dreg\":%u," + "\"len\":%u,", bitwise->sreg, bitwise->dreg, bitwise->len); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, "\"mask\" : {"); + ret = snprintf(buf+offset, len, "\"mask\":{"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = nft_data_reg_snprintf(buf+offset, len, &bitwise->mask, NFT_RULE_O_JSON, 0, DATA_VALUE); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, "}, \"xor\" : {"); + ret = snprintf(buf+offset, len, "},\"xor\":{"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = nft_data_reg_snprintf(buf+offset, len, &bitwise->xor, diff --git a/src/expr/byteorder.c b/src/expr/byteorder.c index f05ddb5..7012452 100644 --- a/src/expr/byteorder.c +++ b/src/expr/byteorder.c @@ -298,11 +298,11 @@ nft_rule_expr_byteorder_snprintf_json(char *buf, size_t size, { int len = size, offset = 0, ret; - ret = snprintf(buf, len, "\"sreg\" : %u, " - "\"dreg\" : %u, " - "\"op\" : \"%s\", " - "\"len\" : %u, " - "\"size\" : %u", + ret = snprintf(buf, len, "\"sreg\":%u," + "\"dreg\":%u," + "\"op\":\"%s\"," + "\"len\":%u," + "\"size\":%u", byteorder->sreg, byteorder->dreg, expr_byteorder_str[byteorder->op], byteorder->len, byteorder->size); diff --git a/src/expr/cmp.c b/src/expr/cmp.c index c6789b6..7de7226 100644 --- a/src/expr/cmp.c +++ b/src/expr/cmp.c @@ -253,7 +253,7 @@ nft_rule_expr_cmp_snprintf_json(char *buf, size_t size, struct nft_expr_cmp *cmp { int len = size, offset = 0, ret; - ret = snprintf(buf, len, "\"sreg\" : %u, \"op\" : \"%s\", \"cmpdata\" : {", + ret = snprintf(buf, len, "\"sreg\":%u,\"op\":\"%s\",\"cmpdata\":{", cmp->sreg, expr_cmp_str[cmp->op]); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); diff --git a/src/expr/counter.c b/src/expr/counter.c index bba9261..561f26c 100644 --- a/src/expr/counter.c +++ b/src/expr/counter.c @@ -180,7 +180,7 @@ nft_rule_expr_counter_snprintf(char *buf, size_t len, uint32_t type, return snprintf(buf, len, "%"PRIu64"%"PRIu64"", ctr->pkts, ctr->bytes); case NFT_RULE_O_JSON: - return snprintf(buf, len, "\"pkts\" : %"PRIu64", \"bytes\" : %"PRIu64"", + return snprintf(buf, len, "\"pkts\":%"PRIu64",\"bytes\":%"PRIu64"", ctr->pkts, ctr->bytes); default: break; diff --git a/src/expr/ct.c b/src/expr/ct.c index bf18c7e..e84d996 100644 --- a/src/expr/ct.c +++ b/src/expr/ct.c @@ -279,17 +279,17 @@ nft_expr_ct_snprintf_json(char *buf, size_t size, struct nft_rule_expr *e) int ret, len = size, offset = 0; struct nft_expr_ct *ct = nft_expr_data(e); - ret = snprintf(buf, len, "\"dreg\" : %u", ct->dreg); + ret = snprintf(buf, len, "\"dreg\":%u", ct->dreg); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); if (e->flags & (1 << NFT_EXPR_CT_KEY)) { - ret = snprintf(buf+offset, len, ", \"key\" : \"%s\"", + ret = snprintf(buf+offset, len, ",\"key\":\"%s\"", ctkey2str(ct->key)); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } if (e->flags & (1 << NFT_EXPR_CT_DIR)) { - ret = snprintf(buf+offset, len, ", \"dir\" : %u", ct->dir); + ret = snprintf(buf+offset, len, ",\"dir\":%u", ct->dir); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } diff --git a/src/expr/data_reg.c b/src/expr/data_reg.c index 2b9ecee..193f3ab 100644 --- a/src/expr/data_reg.c +++ b/src/expr/data_reg.c @@ -216,14 +216,14 @@ nft_data_reg_value_snprintf_json(char *buf, size_t size, uint32_t utemp; uint8_t *tmp; - ret = snprintf(buf, len, "\"data_reg\": { \"type\" : \"value\", "); + ret = snprintf(buf, len, "\"data_reg\":{\"type\":\"value\","); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, "\"len\" : %u, ", reg->len); + ret = snprintf(buf+offset, len, "\"len\":%u,", reg->len); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); for (i = 0; i < div_round_up(reg->len, sizeof(uint32_t)); i++) { - ret = snprintf(buf+offset, len, "\"data%d\" : \"0x", i); + ret = snprintf(buf+offset, len, "\"data%d\":\"0x", i); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); utemp = htonl(reg->val[i]); @@ -234,10 +234,10 @@ nft_data_reg_value_snprintf_json(char *buf, size_t size, SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } - ret = snprintf(buf+offset, len, "\", "); + ret = snprintf(buf+offset, len, "\","); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } - offset -= 2; + offset--; ret = snprintf(buf+offset, len, "}"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -324,9 +324,9 @@ int nft_data_reg_snprintf(char *buf, size_t size, union nft_data_reg *reg, nft_verdict2str(reg->verdict)); case NFT_RULE_O_JSON: return snprintf(buf, size, - "\"data_reg\": {" - "\"type\" : \"verdict\", " - "\"verdict\" : \"%s\"" + "\"data_reg\":{" + "\"type\":\"verdict\"," + "\"verdict\":\"%s\"" "}", nft_verdict2str(reg->verdict)); default: break; @@ -342,8 +342,8 @@ int nft_data_reg_snprintf(char *buf, size_t size, union nft_data_reg *reg, "", reg->chain); case NFT_RULE_O_JSON: return snprintf(buf, size, - "\"data_reg\": { \"type\" : \"chain\", " - "\"chain\" : \"%s\"" + "\"data_reg\":{\"type\":\"chain\"," + "\"chain\":\"%s\"" "}", reg->chain); default: break; diff --git a/src/expr/exthdr.c b/src/expr/exthdr.c index 1290f3f..32791d0 100644 --- a/src/expr/exthdr.c +++ b/src/expr/exthdr.c @@ -302,9 +302,9 @@ nft_rule_expr_exthdr_snprintf(char *buf, size_t len, uint32_t type, exthdr_type2str(exthdr->type), exthdr->offset, exthdr->len); case NFT_RULE_O_JSON: - return snprintf(buf, len, "\"dreg\" : %u, " - "\"exthdr_type\" : \"%s\", \"offset\" : %u, " - "\"len\" : %u", + return snprintf(buf, len, "\"dreg\":%u," + "\"exthdr_type\":\"%s\",\"offset\":%u," + "\"len\":%u", exthdr->dreg, exthdr_type2str(exthdr->type), exthdr->offset, exthdr->len); diff --git a/src/expr/immediate.c b/src/expr/immediate.c index e824801..cb3b209 100644 --- a/src/expr/immediate.c +++ b/src/expr/immediate.c @@ -261,8 +261,8 @@ nft_rule_expr_immediate_snprintf_json(char *buf, size_t len, int size = len, offset = 0, ret; struct nft_expr_immediate *imm = nft_expr_data(e); - ret = snprintf(buf, len, "\"dreg\" : %u, " - "\"immediatedata\" : {", imm->dreg); + ret = snprintf(buf, len, "\"dreg\":%u," + "\"immediatedata\":{", imm->dreg); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); diff --git a/src/expr/limit.c b/src/expr/limit.c index 6954014..bdb0414 100644 --- a/src/expr/limit.c +++ b/src/expr/limit.c @@ -179,8 +179,8 @@ nft_rule_expr_limit_snprintf(char *buf, size_t len, uint32_t type, "%"PRIu64"", limit->rate, limit->depth); case NFT_RULE_O_JSON: - return snprintf(buf, len, "\"rate\" : %"PRIu64", " - "\"depth\" : %"PRIu64" ", + return snprintf(buf, len, "\"rate\":%"PRIu64"," + "\"depth\":%"PRIu64"", limit->rate, limit->depth); default: break; diff --git a/src/expr/log.c b/src/expr/log.c index 0a8e86c..7722d62 100644 --- a/src/expr/log.c +++ b/src/expr/log.c @@ -256,10 +256,10 @@ nft_rule_expr_log_snprintf(char *buf, size_t len, uint32_t type, log->prefix, log->group, log->snaplen, log->qthreshold); case NFT_RULE_O_JSON: - return snprintf(buf, len, "\"prefix\" : \"%s\", " - "\"group\" : %u, " - "\"snaplen\" : %u, " - "\"qthreshold\" : %u ", + return snprintf(buf, len, "\"prefix\":\"%s\"," + "\"group\":%u," + "\"snaplen\":%u," + "\"qthreshold\":%u", log->prefix, log->group, log->snaplen, log->qthreshold); default: diff --git a/src/expr/lookup.c b/src/expr/lookup.c index 1f10e15..e37e295 100644 --- a/src/expr/lookup.c +++ b/src/expr/lookup.c @@ -216,7 +216,7 @@ nft_rule_expr_lookup_snprintf_json(char *buf, size_t size, { int len = size, offset = 0, ret; - ret = snprintf(buf, len, "\"set\" : \"%s\", \"sreg\" : %u, \"dreg\" : %u", + ret = snprintf(buf, len, "\"set\":\"%s\",\"sreg\":%u,\"dreg\":%u", l->set_name, l->sreg, l->dreg); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); diff --git a/src/expr/match.c b/src/expr/match.c index 91e59ff..c03ab12 100644 --- a/src/expr/match.c +++ b/src/expr/match.c @@ -218,7 +218,7 @@ static int nft_rule_expr_match_snprintf_json(char *buf, size_t len, { int ret, size = len, offset = 0; - ret = snprintf(buf, len, "\"name\" : \"%s\"", + ret = snprintf(buf, len, "\"name\":\"%s\"", mt->name); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); diff --git a/src/expr/meta.c b/src/expr/meta.c index 98d83b0..beeb8ca 100644 --- a/src/expr/meta.c +++ b/src/expr/meta.c @@ -239,8 +239,8 @@ nft_rule_expr_meta_snprintf(char *buf, size_t len, uint32_t type, "%s", meta->dreg, meta_key2str(meta->key)); case NFT_RULE_O_JSON: - return snprintf(buf, len, "\"dreg\" : %u, " - "\"key\" : \"%s\"", + return snprintf(buf, len, "\"dreg\":%u," + "\"key\":\"%s\"", meta->dreg, meta_key2str(meta->key)); default: break; diff --git a/src/expr/nat.c b/src/expr/nat.c index 3c40b93..7150eec 100644 --- a/src/expr/nat.c +++ b/src/expr/nat.c @@ -327,28 +327,26 @@ nft_rule_expr_nat_snprintf_json(char *buf, size_t size, int len = size, offset = 0, ret = 0; if (nat->type == NFT_NAT_SNAT) - ret = snprintf(buf, len, "\"nat_type\" : \"snat\", "); + ret = snprintf(buf, len, "\"nat_type\":\"snat\","); else if (nat->type == NFT_NAT_DNAT) - ret = snprintf(buf, len, "\"nat_type\" : \"dnat\", "); + ret = snprintf(buf, len, "\"nat_type\":\"dnat\","); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, "\"family\" : \"%s\", ", + ret = snprintf(buf+offset, len, "\"family\":\"%s\",", nft_family2str(nat->family)); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); if (e->flags & (1 << NFT_EXPR_NAT_REG_ADDR_MIN)) { - ret = snprintf(buf+offset, len, - "\"sreg_addr_min\" : %u, " - "\"sreg_addr_max\" : %u, ", + ret = snprintf(buf+offset, len, "\"sreg_addr_min\":%u," + "\"sreg_addr_max\":%u,", nat->sreg_addr_min, nat->sreg_addr_max); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } if (e->flags & (1 << NFT_EXPR_NAT_REG_PROTO_MIN)) { - ret = snprintf(buf+offset, len, - "\"sreg_proto_min\" : %u, " - "\"sreg_proto_max\" : %u", + ret = snprintf(buf+offset, len, "\"sreg_proto_min\":%u," + "\"sreg_proto_max\":%u", nat->sreg_proto_min, nat->sreg_proto_max); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } diff --git a/src/expr/payload.c b/src/expr/payload.c index d76e2c4..390b8ef 100644 --- a/src/expr/payload.c +++ b/src/expr/payload.c @@ -169,10 +169,10 @@ nft_rule_expr_payload_snprintf_json(char *buf, size_t len, uint32_t flags, { int size = len, offset = 0, ret; - ret = snprintf(buf, len, "\"dreg\" : %u, " - "\"offset\" : %u, " - "\"len\" : %u, " - "\"base\" : \"%s\"", + ret = snprintf(buf, len, "\"dreg\":%u," + "\"offset\":%u," + "\"len\":%u," + "\"base\":\"%s\"", p->dreg, p->offset, p->len, base2str(p->base)); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); diff --git a/src/expr/target.c b/src/expr/target.c index 19eedde..43fb666 100644 --- a/src/expr/target.c +++ b/src/expr/target.c @@ -220,7 +220,7 @@ int nft_rule_exp_target_snprintf_json(char *buf, size_t len, { int ret, size = len, offset = 0; - ret = snprintf(buf, len, "\"name\" : \"%s\"", + ret = snprintf(buf, len, "\"name\":\"%s\"", tg->name); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); diff --git a/src/rule.c b/src/rule.c index 7f2bce6..50f4486 100644 --- a/src/rule.c +++ b/src/rule.c @@ -705,37 +705,35 @@ static int nft_rule_snprintf_json(char *buf, size_t size, struct nft_rule *r, int ret, len = size, offset = 0; struct nft_rule_expr *expr; - ret = snprintf(buf, len, - "{ \"rule\": { \"family\" : \"%s\", \"table\" : \"%s\", " - "\"chain\" : \"%s\", \"handle\" : %llu,", + ret = snprintf(buf, len, "{\"rule\":{\"family\":\"%s\",\"table\":\"%s\"," + "\"chain\":\"%s\",\"handle\":%llu,", nft_family2str(r->family), r->table, r->chain, (unsigned long long)r->handle); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, "\"flags\" : %u, ", r->rule_flags); + ret = snprintf(buf+offset, len, "\"flags\":%u,", r->rule_flags); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); if (r->flags & (1 << NFT_RULE_ATTR_COMPAT_PROTO) || r->flags & (1 << NFT_RULE_ATTR_COMPAT_FLAGS)) { - ret = snprintf(buf+offset, len, "\"compat_flags\" : %u, " - "\"compat_proto\" : %u, ", + ret = snprintf(buf+offset, len, "\"compat_flags\":%u," + "\"compat_proto\":%u,", r->compat.flags, r->compat.proto); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } if (r->flags & (1 << NFT_RULE_ATTR_POSITION)) { - ret = snprintf(buf+offset, len, - "\"position\" : %"PRIu64", ", + ret = snprintf(buf+offset, len, "\"position\":%"PRIu64",", r->position); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } - ret = snprintf(buf+offset, len, "\"expr\" : ["); + ret = snprintf(buf+offset, len, "\"expr\":["); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); list_for_each_entry(expr, &r->expr_list, head) { ret = snprintf(buf+offset, len, - " { \"type\" : \"%s\", ", expr->ops->name); + "{\"type\":\"%s\",", expr->ops->name); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = expr->ops->snprintf(buf+offset, len, type, flags, expr); diff --git a/src/ruleset.c b/src/ruleset.c index 7fdfa4d..8944da6 100644 --- a/src/ruleset.c +++ b/src/ruleset.c @@ -783,7 +783,7 @@ nft_ruleset_snprintf_json(char *buf, size_t size, const struct nft_ruleset *rs, { int ret, len = size, offset = 0; - ret = snprintf(buf, size, "{ \"nftables\": ["); + ret = snprintf(buf, size, "{\"nftables\":["); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = nft_ruleset_do_snprintf(buf+offset, len, rs, NFT_RULESET_O_JSON, diff --git a/src/set.c b/src/set.c index 31185a0..74ec1e3 100644 --- a/src/set.c +++ b/src/set.c @@ -543,10 +543,10 @@ static int nft_set_snprintf_json(char *buf, size_t size, struct nft_set *s, int len = size, offset = 0, ret; struct nft_set_elem *elem; - ret = snprintf(buf, len, "{ \"set\": { \"name\": \"%s\"," - "\"table\": \"%s\"," - "\"flags\": %u,\"family\": \"%s\"," - "\"key_type\": %u,\"key_len\": %u", + ret = snprintf(buf, len, "{\"set\":{\"name\":\"%s\"," + "\"table\":\"%s\"," + "\"flags\":%u,\"family\":\"%s\"," + "\"key_type\":%u,\"key_len\":%u", s->name, s->table, s->set_flags, nft_family2str(s->family), s->key_type, s->key_len); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); @@ -554,7 +554,7 @@ static int nft_set_snprintf_json(char *buf, size_t size, struct nft_set *s, if(s->flags & (1 << NFT_SET_ATTR_DATA_TYPE) && s->flags & (1 << NFT_SET_ATTR_DATA_LEN)){ ret = snprintf(buf+offset, len, - ",\"data_type\": %u,\"data_len\": %u", + ",\"data_type\":%u,\"data_len\":%u", s->data_type, s->data_len); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } @@ -566,7 +566,7 @@ static int nft_set_snprintf_json(char *buf, size_t size, struct nft_set *s, return offset; } - ret = snprintf(buf+offset, len, ",\"set_elem\": ["); + ret = snprintf(buf+offset, len, ",\"set_elem\":["); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); list_for_each_entry(elem, &s->element_list, head) { @@ -576,11 +576,11 @@ static int nft_set_snprintf_json(char *buf, size_t size, struct nft_set *s, ret = nft_set_elem_snprintf(buf+offset, len, elem, type, flags); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, "}, "); + ret = snprintf(buf+offset, len, "},"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); } /* Overwrite trailing ", " from last set element */ - offset -= 2; + offset --; ret = snprintf(buf+offset, len, "]}}"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); diff --git a/src/set_elem.c b/src/set_elem.c index ba24c96..5bb82f6 100644 --- a/src/set_elem.c +++ b/src/set_elem.c @@ -454,10 +454,10 @@ static int nft_set_elem_snprintf_json(char *buf, size_t size, { int ret, len = size, offset = 0, type = -1; - ret = snprintf(buf, len, "\"flags\": %u", e->set_elem_flags); + ret = snprintf(buf, len, "\"flags\":%u", e->set_elem_flags); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); - ret = snprintf(buf+offset, len, ",\"key\": {"); + ret = snprintf(buf+offset, len, ",\"key\":{"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = nft_data_reg_snprintf(buf+offset, len, &e->key, @@ -475,7 +475,7 @@ static int nft_set_elem_snprintf_json(char *buf, size_t size, type = DATA_VERDICT; if (type != -1) { - ret = snprintf(buf+offset, len, ",\"data\": {"); + ret = snprintf(buf+offset, len, ",\"data\":{"); SNPRINTF_BUFFER_SIZE(ret, size, len, offset); ret = nft_data_reg_snprintf(buf+offset, len, &e->data, diff --git a/src/table.c b/src/table.c index 7f14b32..d3ff188 100644 --- a/src/table.c +++ b/src/table.c @@ -349,10 +349,10 @@ EXPORT_SYMBOL(nft_table_parse); static int nft_table_snprintf_json(char *buf, size_t size, struct nft_table *t) { return snprintf(buf, size, - "{\"table\" : {" - "\"name\" : \"%s\"," - "\"family\" : \"%s\"," - "\"flags\" : %d" + "{\"table\":{" + "\"name\":\"%s\"," + "\"family\":\"%s\"," + "\"flags\":%d" "}" "}" , t->name, nft_family2str(t->family), t->table_flags); -- cgit v1.2.3