path: root/file.c
diff options
authorDaan De Meyer <daan.j.demeyer@gmail.com>2017-06-16 15:19:18 +0200
committerAnders Broman <a.broman58@gmail.com>2017-06-22 19:31:01 +0000
commit07f576ffeb2bfabecaefbe24088a2858f47d4642 (patch)
treeee51b1043b254b4b86b8422c5e86d643c81d8cf8 /file.c
parent2954a69d7d5627bf330eb9bb05eb5a1274e01f3a (diff)
Add --no-duplicate-keys tshark option.
Adds the --no-duplicate-keys option to tshark. If -T json is specified, this option can be specified in order to transform the duplicate keys produced by -T json into single keys with as value a json array of all separate values. Specifying --no-duplicate-keys changes the function which groups node children that is passed to write_json_proto_tree. Instead of a function that puts each node in a separate group (proto_node_group_children_by_unique) a function is passed that groups children that have the same json key together (proto_node_group_children_by_json_key). This will lead to some groups having multiple values. Groups with multiple values are written to the output as a json array. This includes normal json keys but also keys with the "_raw" and "_tree" suffix. If --no-duplicate-keys is specified with an option other than "-T json" or "-T jsonraw" or without -T an error is shown and tshark will exit. "Export Packet Dissections -> As JSON" in the GUI is hardcoded to use the duplicated keys format. Fixes one regression in the output where a filtered json key (-j) with both a value and children would not have the "_tree" suffix added to the json key containing the children. Includes a little code cleanup (removes one instance of code duplication and simplifies a while loop). Fixes a memory leak (I thought this fix was already included in the previous refactor patch but something must have gone wrong when updating the patch so I'm including it again in this patch). Bug: 12958 Change-Id: I401f8fc877b5c590686567c3c44cdb832e9e7dfe Reviewed-on: https://code.wireshark.org/review/22166 Petri-Dish: Jaap Keuter <jaap.keuter@xs4all.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
Diffstat (limited to 'file.c')
1 files changed, 1 insertions, 1 deletions
diff --git a/file.c b/file.c
index c9e968005e..a40326b655 100644
--- a/file.c
+++ b/file.c
@@ -2862,7 +2862,7 @@ write_json_packet(capture_file *cf, frame_data *fdata,
/* Write out the information in that tree. */
write_json_proto_tree(NULL, args->print_args->print_dissections,
args->print_args->print_hex, NULL, PF_NONE,
- &args->edt, args->fh);
+ &args->edt, proto_node_group_children_by_unique, args->fh);