aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/scheme/util/utils.cpp
blob: 40cceceacd7a534c2797e45864cde0ed7ec05695 (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
#include "utils.h"

#include <library/cpp/string_utils/base64/base64.h>

namespace NScUtils {

void CopyField(const NSc::TValue& from, NSc::TValue& to) {
    to = from;
}

} // namespace NScUtils

void TSerializer<NSc::TValue>::Save(IOutputStream* out, const NSc::TValue& v) {
    TString json = Base64Encode(v.ToJson());
    ::Save(out, json);
}

void TSerializer<NSc::TValue>::Load(IInputStream* in, NSc::TValue& v) {
    TString json;
    ::Load(in, json);
    json = Base64Decode(json);
    v = NSc::TValue::FromJsonThrow(json);
}