aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-json.c
diff options
context:
space:
mode:
authorHuang Qiangxiong <qiangxiong.huang@qq.com>2022-12-18 19:39:47 +0800
committerAndersBroman <a.broman58@gmail.com>2023-01-03 07:40:06 +0000
commite60dc74d9015112e58e8240de5e1617e62a39762 (patch)
treef62a66d625afb0a36c47cdb949321307a5f1ae65 /epan/dissectors/packet-json.c
parent872db1fe875c141cd28f733e1e3e4675313fd048 (diff)
JSON: fix a displaying two dimensional array bug in compact form
Diffstat (limited to 'epan/dissectors/packet-json.c')
-rw-r--r--epan/dissectors/packet-json.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/epan/dissectors/packet-json.c b/epan/dissectors/packet-json.c
index aa57ded3d0..65588ae3aa 100644
--- a/epan/dissectors/packet-json.c
+++ b/epan/dissectors/packet-json.c
@@ -750,6 +750,21 @@ before_array(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *
json_key_lookup(tree, tok, last_key_string, data->pinfo, FALSE);
if (json_compact) {
+ proto_tree* tree_compact = (proto_tree*)wmem_stack_peek(data->stack_compact);
+ proto_tree* subtree_compact;
+ proto_item* ti_compact;
+
+ gint idx = GPOINTER_TO_INT(wmem_stack_peek(data->array_idx));
+
+ if (JSON_INSIDE_ARRAY(idx)) {
+ ti_compact = proto_tree_add_none_format(tree_compact, hf_json_array_compact, tok->tvb, tok->offset, tok->len, "%d:", idx);
+ subtree_compact = proto_item_add_subtree(ti_compact, ett_json_array_compact);
+ json_array_index_increment(data);
+ } else {
+ subtree_compact = tree_compact;
+ }
+ wmem_stack_push(data->stack_compact, subtree_compact);
+
JSON_ARRAY_BEGIN(data);
}
}
@@ -774,6 +789,8 @@ after_array(void *tvbparse_data, const void *wanted_data _U_, tvbparse_elem_t *e
else
proto_item_append_text(parent_item, " [...]");
+ wmem_stack_pop(data->stack_compact);
+
JSON_ARRAY_OBJECT_END(data);
}
}