mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 12:38:20 +00:00
from_json: Support function to normalize key names
When a JSON document contains key names containing colons or other special characters that are not valid in Zeek identifiers, from_json() cannot be used to parse such input. This change allows a customizable normalization function. Closes #3142.
This commit is contained in:
parent
3a8b299c35
commit
480d52ca1f
14 changed files with 102 additions and 29 deletions
|
@ -1800,7 +1800,11 @@ namespace detail
|
|||
// Parses a JSON string into arbitrary Zeek data using std::variant to simulate functional exception
|
||||
// handling. Returns a ValPtr if parsing was successful, or a std::string containing an error
|
||||
// message if an error occurred.
|
||||
extern std::variant<ValPtr, std::string> ValFromJSON(std::string_view json_str, const TypePtr& t);
|
||||
//
|
||||
// The *key_func* parameter is a Zeek script function called for every JSON key
|
||||
// for normalization. If Func::nil is passed, no normalization happens.
|
||||
extern std::variant<ValPtr, std::string> ValFromJSON(std::string_view json_str, const TypePtr& t,
|
||||
const FuncPtr& key_func);
|
||||
}
|
||||
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue