mirror of
https://github.com/zeek/zeek.git
synced 2025-10-15 21:18:20 +00:00
Fix the to_json() function for bool, enum, and interval types
This commit is contained in:
parent
9370db8980
commit
65d6e5a4f7
2 changed files with 12 additions and 8 deletions
|
@ -25,6 +25,10 @@ function to_json(v: any, only_loggable: bool &default=F, field_escape_pattern: p
|
||||||
case "port":
|
case "port":
|
||||||
return cat(port_to_count(to_port(cat(v))));
|
return cat(port_to_count(to_port(cat(v))));
|
||||||
|
|
||||||
|
case "enum":
|
||||||
|
fallthrough;
|
||||||
|
case "interval":
|
||||||
|
fallthrough;
|
||||||
case "addr":
|
case "addr":
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case "subnet":
|
case "subnet":
|
||||||
|
@ -37,12 +41,12 @@ function to_json(v: any, only_loggable: bool &default=F, field_escape_pattern: p
|
||||||
case "time":
|
case "time":
|
||||||
fallthrough;
|
fallthrough;
|
||||||
case "double":
|
case "double":
|
||||||
fallthrough;
|
|
||||||
case "bool":
|
|
||||||
fallthrough;
|
|
||||||
case "enum":
|
|
||||||
return cat(v);
|
return cat(v);
|
||||||
|
|
||||||
|
case "bool":
|
||||||
|
local bval: bool = v;
|
||||||
|
return bval ? "true" : "false";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
T
|
true
|
||||||
123
|
123
|
||||||
-999
|
-999
|
||||||
1.123457
|
1.123457
|
||||||
-1.123456e+308
|
-1.123456e+308
|
||||||
0
|
0
|
||||||
1.0
|
1.0
|
||||||
""
|
"-12.0 hrs"
|
||||||
"hello"
|
"hello"
|
||||||
""
|
""
|
||||||
65535
|
65535
|
||||||
|
@ -17,7 +17,7 @@ T
|
||||||
"123.123.123.123"
|
"123.123.123.123"
|
||||||
"192.0.0.0/8"
|
"192.0.0.0/8"
|
||||||
"fe80::/64"
|
"fe80::/64"
|
||||||
Red
|
"Red"
|
||||||
{"s": "test", "c": 100}
|
{"s": "test", "c": 100}
|
||||||
{"s": "test"}
|
{"s": "test"}
|
||||||
{"s": "test"}
|
{"s": "test"}
|
||||||
|
@ -25,7 +25,7 @@ Red
|
||||||
[]
|
[]
|
||||||
[2, 1]
|
[2, 1]
|
||||||
["1.2.3.4"]
|
["1.2.3.4"]
|
||||||
[[T, F]]
|
[[true, false]]
|
||||||
[{"s": "test"}]
|
[{"s": "test"}]
|
||||||
[]
|
[]
|
||||||
[2, 1]
|
[2, 1]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue