diff options
| author | ionagamed <[email protected]> | 2023-12-06 11:15:42 +0300 |
|---|---|---|
| committer | ionagamed <[email protected]> | 2023-12-06 11:59:15 +0300 |
| commit | bbdd76a9666c19dd2eb27a842909358e8b541a67 (patch) | |
| tree | 4dd28e53f070d9f33c58df8631357e0b7125ce54 /library/cpp/yson/node/node_io.h | |
| parent | 19dfab524551ce06a74e89eda1a7dd2c95663e9c (diff) | |
library/yson: Add NodeFromJsonStringIterative
AI для
Diffstat (limited to 'library/cpp/yson/node/node_io.h')
| -rw-r--r-- | library/cpp/yson/node/node_io.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/library/cpp/yson/node/node_io.h b/library/cpp/yson/node/node_io.h index 02067045b83..1348d88bbb1 100644 --- a/library/cpp/yson/node/node_io.h +++ b/library/cpp/yson/node/node_io.h @@ -33,6 +33,12 @@ void NodeToCanonicalYsonStream(const TNode& node, IOutputStream* output, ::NYson TNode NodeFromJsonString(const TStringBuf input); bool TryNodeFromJsonString(const TStringBuf input, TNode& dst); +// Parse TNode from string in JSON format using an iterative JSON parser. +// Iterative JSON parsers still use the stack, but allocate it on the heap (instead of using the system call stack). +// Needed to mitigate stack overflow with short stacks on deeply nested JSON strings +// (e.g. 256kb of stack when parsing "[[[[[[...]]]]]]" crashes the whole binary). +TNode NodeFromJsonStringIterative(const TStringBuf input, ui64 maxDepth = 1024); + // Convert TJsonValue to TNode TNode NodeFromJsonValue(const ::NJson::TJsonValue& input); |
