JSON: print field value for an item containing a subtree

For fields that contain both a value and a subtree, print the value and
then create a new item with a _tree suffix for the subtree content

Bug: 13086
Change-Id: I5a3c96bf9895d87faff3925d439bb54b73769a3e
Reviewed-on: https://code.wireshark.org/review/18663
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Martin Kacer <kacer.martin@gmail.com>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
Pascal Quantin 2016-11-04 07:45:09 +01:00
parent 3814eee112
commit 1b91475e0d
1 changed files with 18 additions and 18 deletions

View File

@ -378,7 +378,7 @@ write_json_proto_tree(output_fields_t* fields, print_args_t *print_args, gchar *
fputs(" }\n", fh);
fputs(" }\n", fh);
fputs(" }", fh);
fputs(" }\n", fh);
}
@ -831,11 +831,17 @@ proto_tree_write_node_json(proto_node *node, gpointer data)
default:
dfilter_string = fvalue_to_string_repr(NULL, &fi->value, FTREPR_DISPLAY, fi->hfinfo->display);
if (dfilter_string != NULL) {
if (node->first_child == NULL) {
fputs("\": \"", pdata->fh);
print_escaped_json(pdata->fh, dfilter_string);
} else {
fputs("\": {\n", pdata->fh);
fputs("\": \"", pdata->fh);
print_escaped_json(pdata->fh, dfilter_string);
if (node->first_child != NULL) {
fputs("\",\n", pdata->fh);
/* Indent to the correct level */
for (i = -3; i < pdata->level; i++) {
fputs(" ", pdata->fh);
}
fputs("\"", pdata->fh);
print_escaped_json(pdata->fh, fi->hfinfo->abbrev);
fputs("_tree\": {\n", pdata->fh);
}
}
wmem_free(NULL, dfilter_string);
@ -1036,21 +1042,15 @@ proto_tree_write_node_ek(proto_node *node, gpointer data)
default:
dfilter_string = fvalue_to_string_repr(NULL, &fi->value, FTREPR_DISPLAY, fi->hfinfo->display);
if (dfilter_string != NULL) {
if (node->first_child == NULL) {
fputs("\": \"", pdata->fh);
print_escaped_json(pdata->fh, dfilter_string);
} else {
fputs("\": \"\",", pdata->fh);
}
fputs("\": \"", pdata->fh);
print_escaped_json(pdata->fh, dfilter_string);
}
wmem_free(NULL, dfilter_string);
if (node->first_child == NULL) {
if (node->next == NULL) {
fputs("\"", pdata->fh);
} else {
fputs("\",", pdata->fh);
}
if (node->next == NULL) {
fputs("\"", pdata->fh);
} else {
fputs("\",", pdata->fh);
}
}