From e619d6fcd974848970e32d14fa55508931ac359f Mon Sep 17 00:00:00 2001
From: yurial <yurial@yandex-team.com>
Date: Mon, 20 Mar 2023 19:43:07 +0300
Subject: fixup: now AllowComments worked prepertly when using non-stream
 prototype of Json2Proto

---
 library/cpp/protobuf/json/json2proto.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

(limited to 'library/cpp')

diff --git a/library/cpp/protobuf/json/json2proto.h b/library/cpp/protobuf/json/json2proto.h
index ed89c6cf63..d576fabce7 100644
--- a/library/cpp/protobuf/json/json2proto.h
+++ b/library/cpp/protobuf/json/json2proto.h
@@ -202,6 +202,7 @@ namespace NProtobufJson {
     /// @throw yexception
     template <typename T>
     T Json2Proto(IInputStream& in, const TJson2ProtoConfig& config = TJson2ProtoConfig()) {
+        // NOTE: TJson2ProtoConfig.AllowComments=true doesn't work, when using TJsonReaderConfig
         NJson::TJsonReaderConfig readerConfig;
         readerConfig.DontValidateUtf8 = true;
         return Json2Proto<T>(in, readerConfig, config);
@@ -210,15 +211,15 @@ namespace NProtobufJson {
     /// @throw yexception
     template <typename T>
     T Json2Proto(const TString& value, const TJson2ProtoConfig& config = TJson2ProtoConfig()) {
-        TStringInput in(value);
-        return Json2Proto<T>(in, config);
+        return Json2Proto<T>(TStringBuf(value), config);
     }
 
     /// @throw yexception
     template <typename T>
     T Json2Proto(const TStringBuf& value, const TJson2ProtoConfig& config = TJson2ProtoConfig()) {
-        TMemoryInput in(value);
-        return Json2Proto<T>(in, config);
+        T protoValue;
+        Json2Proto(value, protoValue, config);
+        return protoValue;
     }
 
     /// @throw yexception
-- 
cgit v1.2.3