Revert changes to JSON boolean format
We should represent JSON values in JSON,
such as booleans using true/false.
The changes in cdc8e2f511
didn't actually fix anything for JSON output in that
regard, they just replace one string representation with
a different incorrect representation, so revert the part
affecting JSON to avoid inconveniencing users without
sufficient justification.
This commit is contained in:
parent
6bc8c6c682
commit
051c8cb7b3
|
@ -1156,11 +1156,22 @@ boolean_from_string(fvalue_t *fv, const char *s, size_t len, char **err_msg _U_)
|
|||
}
|
||||
|
||||
static char *
|
||||
boolean_to_repr(wmem_allocator_t *scope, const fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_)
|
||||
boolean_to_repr(wmem_allocator_t *scope, const fvalue_t *fv, ftrepr_t rtype, int field_display _U_)
|
||||
{
|
||||
if (fv->value.uinteger64)
|
||||
return wmem_strdup(scope, "True");
|
||||
return wmem_strdup(scope, "False");
|
||||
bool val = fv->value.uinteger64;
|
||||
const char *str = NULL;
|
||||
|
||||
switch (rtype) {
|
||||
case FTREPR_DFILTER:
|
||||
case FTREPR_DISPLAY:
|
||||
str = val ? "True" : "False";
|
||||
break;
|
||||
case FTREPR_JSON:
|
||||
str = val ? "1" : "0";
|
||||
break;
|
||||
}
|
||||
|
||||
return wmem_strdup(scope, str);
|
||||
}
|
||||
|
||||
/* False is less than True (arbitrary):
|
||||
|
|
|
@ -49,7 +49,7 @@ string_fvalue_set_strbuf(fvalue_t *fv, wmem_strbuf_t *value)
|
|||
static char *
|
||||
string_to_repr(wmem_allocator_t *scope, const fvalue_t *fv, ftrepr_t rtype _U_, int field_display _U_)
|
||||
{
|
||||
if (rtype == FTREPR_DISPLAY) {
|
||||
if (rtype == FTREPR_DISPLAY || rtype == FTREPR_JSON) {
|
||||
return ws_escape_null(scope, fv->value.strbuf->str, fv->value.strbuf->len, false);
|
||||
}
|
||||
if (rtype == FTREPR_DFILTER) {
|
||||
|
|
|
@ -440,6 +440,7 @@ absolute_val_to_repr(wmem_allocator_t *scope, const fvalue_t *fv, ftrepr_t rtype
|
|||
|
||||
switch (rtype) {
|
||||
case FTREPR_DISPLAY:
|
||||
case FTREPR_JSON:
|
||||
rep = abs_time_to_str_ex(scope, &fv->value.time,
|
||||
field_display, ABS_TIME_TO_STR_SHOW_ZONE);
|
||||
break;
|
||||
|
|
|
@ -165,7 +165,8 @@ typedef bool ft_bool_t;
|
|||
/* String representation types. */
|
||||
enum ftrepr {
|
||||
FTREPR_DISPLAY,
|
||||
FTREPR_DFILTER
|
||||
FTREPR_DFILTER,
|
||||
FTREPR_JSON,
|
||||
};
|
||||
|
||||
typedef enum ftrepr ftrepr_t;
|
||||
|
|
|
@ -821,7 +821,7 @@ write_json_proto_node_list(GSList *proto_node_list_head, write_json_data *pdata)
|
|||
gboolean is_filtered = pdata->filter != NULL && !check_protocolfilter(pdata->filter, json_key, &filter_flags);
|
||||
|
||||
field_info *fi = first_value->finfo;
|
||||
char *value_string_repr = fvalue_to_string_repr(NULL, fi->value, FTREPR_DISPLAY, fi->hfinfo->display);
|
||||
char *value_string_repr = fvalue_to_string_repr(NULL, fi->value, FTREPR_JSON, fi->hfinfo->display);
|
||||
gboolean has_children = any_has_children(node_values_list);
|
||||
|
||||
// We assume all values of a json key have roughly the same layout. Thus we can use the first value to derive
|
||||
|
@ -1032,8 +1032,10 @@ write_json_proto_node_value(proto_node *node, write_json_data *pdata)
|
|||
{
|
||||
field_info *fi = node->finfo;
|
||||
// Get the actual value of the node as a string.
|
||||
char *value_string_repr = fvalue_to_string_repr(NULL, fi->value, FTREPR_DISPLAY, fi->hfinfo->display);
|
||||
char *value_string_repr = fvalue_to_string_repr(NULL, fi->value, FTREPR_JSON, fi->hfinfo->display);
|
||||
|
||||
//TODO: Have FTREPR_JSON include quotes where appropriate and use json_dumper_value_anyf() here,
|
||||
// so we can output booleans and numbers and not only strings.
|
||||
json_dumper_value_string(pdata->dumper, value_string_repr);
|
||||
|
||||
wmem_free(NULL, value_string_repr);
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
"frame.number": "1",
|
||||
"frame.len": "314",
|
||||
"frame.cap_len": "314",
|
||||
"frame.marked": "False",
|
||||
"frame.ignored": "False",
|
||||
"frame.marked": "0",
|
||||
"frame.ignored": "0",
|
||||
"frame.protocols": "eth:ethertype:ip:udp:dhcp"
|
||||
},
|
||||
"eth": {
|
||||
|
@ -29,10 +29,10 @@
|
|||
"eth.addr": "ff:ff:ff:ff:ff:ff",
|
||||
"eth.addr_resolved": "Broadcast",
|
||||
"eth.addr.oui": "16777215",
|
||||
"eth.dst.lg": "True",
|
||||
"eth.lg": "True",
|
||||
"eth.dst.ig": "True",
|
||||
"eth.ig": "True"
|
||||
"eth.dst.lg": "1",
|
||||
"eth.lg": "1",
|
||||
"eth.dst.ig": "1",
|
||||
"eth.ig": "1"
|
||||
},
|
||||
"eth.src": "00:0b:82:01:fc:42",
|
||||
"eth.src_tree": {
|
||||
|
@ -43,10 +43,10 @@
|
|||
"eth.addr_resolved": "GrandstreamN_01:fc:42",
|
||||
"eth.addr.oui": "2946",
|
||||
"eth.addr.oui_resolved": "Grandstream Networks, Inc.",
|
||||
"eth.src.lg": "False",
|
||||
"eth.lg": "False",
|
||||
"eth.src.ig": "False",
|
||||
"eth.ig": "False"
|
||||
"eth.src.lg": "0",
|
||||
"eth.lg": "0",
|
||||
"eth.src.ig": "0",
|
||||
"eth.ig": "0"
|
||||
},
|
||||
"eth.type": "0x0800"
|
||||
},
|
||||
|
@ -62,9 +62,9 @@
|
|||
"ip.id": "0xa836",
|
||||
"ip.flags": "0x00",
|
||||
"ip.flags_tree": {
|
||||
"ip.flags.rb": "False",
|
||||
"ip.flags.df": "False",
|
||||
"ip.flags.mf": "False"
|
||||
"ip.flags.rb": "0",
|
||||
"ip.flags.df": "0",
|
||||
"ip.flags.mf": "0"
|
||||
},
|
||||
"ip.frag_offset": "0",
|
||||
"ip.ttl": "250",
|
||||
|
@ -104,7 +104,7 @@
|
|||
"dhcp.secs": "0",
|
||||
"dhcp.flags": "0x0000",
|
||||
"dhcp.flags_tree": {
|
||||
"dhcp.flags.bc": "False",
|
||||
"dhcp.flags.bc": "0",
|
||||
"dhcp.flags.reserved": "0x0000"
|
||||
},
|
||||
"dhcp.ip.client": "0.0.0.0",
|
||||
|
@ -171,8 +171,8 @@
|
|||
"frame.number": "2",
|
||||
"frame.len": "342",
|
||||
"frame.cap_len": "342",
|
||||
"frame.marked": "False",
|
||||
"frame.ignored": "False",
|
||||
"frame.marked": "0",
|
||||
"frame.ignored": "0",
|
||||
"frame.protocols": "eth:ethertype:ip:udp:dhcp"
|
||||
},
|
||||
"eth": {
|
||||
|
@ -185,10 +185,10 @@
|
|||
"eth.addr_resolved": "GrandstreamN_01:fc:42",
|
||||
"eth.addr.oui": "2946",
|
||||
"eth.addr.oui_resolved": "Grandstream Networks, Inc.",
|
||||
"eth.dst.lg": "False",
|
||||
"eth.lg": "False",
|
||||
"eth.dst.ig": "False",
|
||||
"eth.ig": "False"
|
||||
"eth.dst.lg": "0",
|
||||
"eth.lg": "0",
|
||||
"eth.dst.ig": "0",
|
||||
"eth.ig": "0"
|
||||
},
|
||||
"eth.src": "00:08:74:ad:f1:9b",
|
||||
"eth.src_tree": {
|
||||
|
@ -199,10 +199,10 @@
|
|||
"eth.addr_resolved": "Dell_ad:f1:9b",
|
||||
"eth.addr.oui": "2164",
|
||||
"eth.addr.oui_resolved": "Dell Inc.",
|
||||
"eth.src.lg": "False",
|
||||
"eth.lg": "False",
|
||||
"eth.src.ig": "False",
|
||||
"eth.ig": "False"
|
||||
"eth.src.lg": "0",
|
||||
"eth.lg": "0",
|
||||
"eth.src.ig": "0",
|
||||
"eth.ig": "0"
|
||||
},
|
||||
"eth.type": "0x0800"
|
||||
},
|
||||
|
@ -218,9 +218,9 @@
|
|||
"ip.id": "0x0445",
|
||||
"ip.flags": "0x00",
|
||||
"ip.flags_tree": {
|
||||
"ip.flags.rb": "False",
|
||||
"ip.flags.df": "False",
|
||||
"ip.flags.mf": "False"
|
||||
"ip.flags.rb": "0",
|
||||
"ip.flags.df": "0",
|
||||
"ip.flags.mf": "0"
|
||||
},
|
||||
"ip.frag_offset": "0",
|
||||
"ip.ttl": "128",
|
||||
|
@ -260,7 +260,7 @@
|
|||
"dhcp.secs": "0",
|
||||
"dhcp.flags": "0x0000",
|
||||
"dhcp.flags_tree": {
|
||||
"dhcp.flags.bc": "False",
|
||||
"dhcp.flags.bc": "0",
|
||||
"dhcp.flags.reserved": "0x0000"
|
||||
},
|
||||
"dhcp.ip.client": "0.0.0.0",
|
||||
|
@ -335,8 +335,8 @@
|
|||
"frame.number": "3",
|
||||
"frame.len": "314",
|
||||
"frame.cap_len": "314",
|
||||
"frame.marked": "False",
|
||||
"frame.ignored": "False",
|
||||
"frame.marked": "0",
|
||||
"frame.ignored": "0",
|
||||
"frame.protocols": "eth:ethertype:ip:udp:dhcp"
|
||||
},
|
||||
"eth": {
|
||||
|
@ -347,10 +347,10 @@
|
|||
"eth.addr": "ff:ff:ff:ff:ff:ff",
|
||||
"eth.addr_resolved": "Broadcast",
|
||||
"eth.addr.oui": "16777215",
|
||||
"eth.dst.lg": "True",
|
||||
"eth.lg": "True",
|
||||
"eth.dst.ig": "True",
|
||||
"eth.ig": "True"
|
||||
"eth.dst.lg": "1",
|
||||
"eth.lg": "1",
|
||||
"eth.dst.ig": "1",
|
||||
"eth.ig": "1"
|
||||
},
|
||||
"eth.src": "00:0b:82:01:fc:42",
|
||||
"eth.src_tree": {
|
||||
|
@ -361,10 +361,10 @@
|
|||
"eth.addr_resolved": "GrandstreamN_01:fc:42",
|
||||
"eth.addr.oui": "2946",
|
||||
"eth.addr.oui_resolved": "Grandstream Networks, Inc.",
|
||||
"eth.src.lg": "False",
|
||||
"eth.lg": "False",
|
||||
"eth.src.ig": "False",
|
||||
"eth.ig": "False"
|
||||
"eth.src.lg": "0",
|
||||
"eth.lg": "0",
|
||||
"eth.src.ig": "0",
|
||||
"eth.ig": "0"
|
||||
},
|
||||
"eth.type": "0x0800"
|
||||
},
|
||||
|
@ -380,9 +380,9 @@
|
|||
"ip.id": "0xa837",
|
||||
"ip.flags": "0x00",
|
||||
"ip.flags_tree": {
|
||||
"ip.flags.rb": "False",
|
||||
"ip.flags.df": "False",
|
||||
"ip.flags.mf": "False"
|
||||
"ip.flags.rb": "0",
|
||||
"ip.flags.df": "0",
|
||||
"ip.flags.mf": "0"
|
||||
},
|
||||
"ip.frag_offset": "0",
|
||||
"ip.ttl": "250",
|
||||
|
@ -422,7 +422,7 @@
|
|||
"dhcp.secs": "0",
|
||||
"dhcp.flags": "0x0000",
|
||||
"dhcp.flags_tree": {
|
||||
"dhcp.flags.bc": "False",
|
||||
"dhcp.flags.bc": "0",
|
||||
"dhcp.flags.reserved": "0x0000"
|
||||
},
|
||||
"dhcp.ip.client": "0.0.0.0",
|
||||
|
@ -495,8 +495,8 @@
|
|||
"frame.number": "4",
|
||||
"frame.len": "342",
|
||||
"frame.cap_len": "342",
|
||||
"frame.marked": "False",
|
||||
"frame.ignored": "False",
|
||||
"frame.marked": "0",
|
||||
"frame.ignored": "0",
|
||||
"frame.protocols": "eth:ethertype:ip:udp:dhcp"
|
||||
},
|
||||
"eth": {
|
||||
|
@ -509,10 +509,10 @@
|
|||
"eth.addr_resolved": "GrandstreamN_01:fc:42",
|
||||
"eth.addr.oui": "2946",
|
||||
"eth.addr.oui_resolved": "Grandstream Networks, Inc.",
|
||||
"eth.dst.lg": "False",
|
||||
"eth.lg": "False",
|
||||
"eth.dst.ig": "False",
|
||||
"eth.ig": "False"
|
||||
"eth.dst.lg": "0",
|
||||
"eth.lg": "0",
|
||||
"eth.dst.ig": "0",
|
||||
"eth.ig": "0"
|
||||
},
|
||||
"eth.src": "00:08:74:ad:f1:9b",
|
||||
"eth.src_tree": {
|
||||
|
@ -523,10 +523,10 @@
|
|||
"eth.addr_resolved": "Dell_ad:f1:9b",
|
||||
"eth.addr.oui": "2164",
|
||||
"eth.addr.oui_resolved": "Dell Inc.",
|
||||
"eth.src.lg": "False",
|
||||
"eth.lg": "False",
|
||||
"eth.src.ig": "False",
|
||||
"eth.ig": "False"
|
||||
"eth.src.lg": "0",
|
||||
"eth.lg": "0",
|
||||
"eth.src.ig": "0",
|
||||
"eth.ig": "0"
|
||||
},
|
||||
"eth.type": "0x0800"
|
||||
},
|
||||
|
@ -542,9 +542,9 @@
|
|||
"ip.id": "0x0446",
|
||||
"ip.flags": "0x00",
|
||||
"ip.flags_tree": {
|
||||
"ip.flags.rb": "False",
|
||||
"ip.flags.df": "False",
|
||||
"ip.flags.mf": "False"
|
||||
"ip.flags.rb": "0",
|
||||
"ip.flags.df": "0",
|
||||
"ip.flags.mf": "0"
|
||||
},
|
||||
"ip.frag_offset": "0",
|
||||
"ip.ttl": "128",
|
||||
|
@ -584,7 +584,7 @@
|
|||
"dhcp.secs": "0",
|
||||
"dhcp.flags": "0x0000",
|
||||
"dhcp.flags_tree": {
|
||||
"dhcp.flags.bc": "False",
|
||||
"dhcp.flags.bc": "0",
|
||||
"dhcp.flags.reserved": "0x0000"
|
||||
},
|
||||
"dhcp.ip.client": "0.0.0.0",
|
||||
|
|
Loading…
Reference in New Issue