aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/protobuf/json/json_writer_output.cpp
blob: a8e060c53c69d2db5be705dffdc8a0d6c4824903 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#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;
        jsonConfig.DoubleNDigits = config.DoubleNDigits;
        jsonConfig.FloatNDigits = config.FloatNDigits;
        jsonConfig.FloatToStringMode = config.FloatToStringMode;

        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;
    }

}