aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/json/json_writer_output.cpp
blob: 288f645bab06e998d6f50552203fcb913796db92 (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;
    }

}