mirror of
https://github.com/zeek/zeek.git
synced 2025-10-13 20:18:20 +00:00
Merge remote-tracking branch 'origin/topic/jsiwek/gh-282'
Closes #282. * origin/topic/jsiwek/gh-282: GH-282: Remove JSON formatter's range restriction on numbers
This commit is contained in:
commit
aab2d186f4
1 changed files with 3 additions and 19 deletions
|
@ -77,17 +77,8 @@ bool JSON::Describe(ODesc* desc, Value* val, const string& name) const
|
||||||
|
|
||||||
case TYPE_COUNT:
|
case TYPE_COUNT:
|
||||||
case TYPE_COUNTER:
|
case TYPE_COUNTER:
|
||||||
{
|
desc->Add(val->val.uint_val);
|
||||||
// JSON doesn't support unsigned 64bit ints.
|
|
||||||
if ( val->val.uint_val >= INT64_MAX )
|
|
||||||
{
|
|
||||||
GetThread()->Error(GetThread()->Fmt("count value too large for JSON: %" PRIu64, val->val.uint_val));
|
|
||||||
desc->AddRaw("null", 4);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
desc->Add(val->val.uint_val);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case TYPE_PORT:
|
case TYPE_PORT:
|
||||||
desc->Add(val->val.port_val.port);
|
desc->Add(val->val.port_val.port);
|
||||||
|
@ -149,16 +140,9 @@ bool JSON::Describe(ODesc* desc, Value* val, const string& name) const
|
||||||
|
|
||||||
else if ( timestamps == TS_MILLIS )
|
else if ( timestamps == TS_MILLIS )
|
||||||
{
|
{
|
||||||
// ElasticSearch uses milliseconds for timestamps and json only
|
// ElasticSearch uses milliseconds for timestamps
|
||||||
// supports signed ints (uints can be too large).
|
|
||||||
uint64_t ts = (uint64_t) (val->val.double_val * 1000);
|
uint64_t ts = (uint64_t) (val->val.double_val * 1000);
|
||||||
if ( ts < INT64_MAX )
|
desc->Add(ts);
|
||||||
desc->Add(ts);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
GetThread()->Error(GetThread()->Fmt("time value too large for JSON milliseconds: %" PRIu64, ts));
|
|
||||||
desc->AddRaw("null", 4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue