aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/json/json_writer_output.cpp
blob: b4ef84850c8155eaab341a2a42de9de307d8553c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "json_writer_output.h"

namespace NProtobufJson {
    NJson::TJsonWriterConfig TJsonWriterOutput::CreateJsonWriterConfig(const TProto2JsonConfig& config) { 
        NJson::TJsonWriterConfig jsonConfig; 
        jsonConfig.FormatOutput = config.FormatOutput; 
        jsonConfig.SortKeys = false; 
        jsonConfig.ValidateUtf8 = false; 
        jsonConfig.DontEscapeStrings = false; 
        jsonConfig.WriteNanAsString = config.WriteNanAsString;

        for (size_t i = 0; i < config.StringTransforms.size(); ++i) { 
            Y_ASSERT(config.StringTransforms[i]); 
            if (config.StringTransforms[i]->GetType() == IStringTransform::EscapeTransform) { 
                jsonConfig.DontEscapeStrings = true; 
                break; 
            } 
        }
        return jsonConfig; 
    }
 
}