path: root/src/json.c
diff options
authorPhil Sutter <>2018-08-29 16:23:22 +0200
committerPablo Neira Ayuso <>2018-08-30 12:19:36 +0200
commit2a4a5a2c8ae21f2bcf7e81b5eafea91d799ee88a (patch)
tree6dc5e3d0c196c6ec2bff0d22367c0875bdb32f92 /src/json.c
parent0ab82a84ddd25f742f18c1becbf78a74fcec2dce (diff)
JSON: Make meta statement/expression extensible
Lessons learned from fwd statement: We must not assume a given statement/expression may not receive further properties in the future. Therefore make meta value an object with a property "key" instead of just a string containing the key name. Signed-off-by: Phil Sutter <> Signed-off-by: Pablo Neira Ayuso <>
Diffstat (limited to 'src/json.c')
1 files changed, 4 insertions, 2 deletions
diff --git a/src/json.c b/src/json.c
index e8870a13..0c708c7d 100644
--- a/src/json.c
+++ b/src/json.c
@@ -409,7 +409,8 @@ json_t *range_expr_json(const struct expr *expr, struct output_ctx *octx)
json_t *meta_expr_json(const struct expr *expr, struct output_ctx *octx)
- return json_pack("{s:s}", "meta", meta_templates[expr->meta.key].token);
+ return json_pack("{s:{s:s}}", "meta",
+ "key", meta_templates[expr->meta.key].token);
json_t *payload_expr_json(const struct expr *expr, struct output_ctx *octx)
@@ -1049,7 +1050,8 @@ json_t *meta_stmt_json(const struct stmt *stmt, struct output_ctx *octx)
json_t *root;
- root = json_pack("{s:s}", "meta", meta_templates[stmt->meta.key].token);
+ root = json_pack("{s:{s:s}}", "meta",
+ "key", meta_templates[stmt->meta.key].token);
root = json_pack("{s:o, s:o}",
"left", root,
"right", expr_print_json(stmt->meta.expr, octx));