diff mbox series

[nft,3/4] json: Print range expressions numerically

Message ID 20180911201427.25896-4-phil@nwl.cc
State Accepted
Delegated to: Pablo Neira
Headers show
Series Apply some recent changes to JSON output | expand

Commit Message

Phil Sutter Sept. 11, 2018, 8:14 p.m. UTC
This applies the same change as in commit 85b1e3c0052ef ("src: Always
print range expressions numerically") to JSON output for consistency.

Signed-off-by: Phil Sutter <phil@nwl.cc>
---
 src/json.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/json.c b/src/json.c
index c0fc42263c1a0..1708f22dda408 100644
--- a/src/json.c
+++ b/src/json.c
@@ -393,9 +393,15 @@  json_t *relational_expr_json(const struct expr *expr, struct output_ctx *octx)
 
 json_t *range_expr_json(const struct expr *expr, struct output_ctx *octx)
 {
-	return json_pack("{s:[o, o]}", "range",
+	json_t *root;
+
+	octx->numeric += NFT_NUMERIC_ALL + 1;
+	root = json_pack("{s:[o, o]}", "range",
 			 expr_print_json(expr->left, octx),
 			 expr_print_json(expr->right, octx));
+	octx->numeric -= NFT_NUMERIC_ALL + 1;
+
+	return root;
 }
 
 json_t *meta_expr_json(const struct expr *expr, struct output_ctx *octx)