Document the field_escape_pattern in the to_json() BiF

This argument, and its corresponding use in Val.cc's BuildJSON(),
were never explained.
This commit is contained in:
Christian Kreibich 2024-06-21 17:45:59 -07:00
parent c2dd3dfad0
commit a29f862f95
3 changed files with 41 additions and 2 deletions

View file

@ -329,8 +329,27 @@ TableValPtr Val::GetRecordFields() {
return rt->GetRecordFieldsVal(rv);
}
// This is a static method in this file to avoid including rapidjson's headers in Val.h because
// they're huge.
// A predicate to identify those types we render as a string in JSON.
static bool IsQuotedJSONType(const TypePtr& t) {
if ( t == nullptr )
return false;
switch ( t->Tag() ) {
case TYPE_ADDR:
case TYPE_ENUM:
case TYPE_FILE:
case TYPE_FUNC:
case TYPE_INTERVAL:
case TYPE_PATTERN:
case TYPE_STRING:
case TYPE_SUBNET:
case TYPE_OPAQUE: return true;
default: return false;
}
}
// This is a static method in this file to avoid including rapidjson's headers
// in Val.h, because they're huge.
static void BuildJSON(json::detail::NullDoubleWriter& writer, Val* val, bool only_loggable = false,
RE_Matcher* re = nullptr, const string& key = "") {
if ( ! key.empty() )