utils.cpp 535 B

1234567891011121314151617181920212223
  1. #include "utils.h"
  2. #include <library/cpp/string_utils/base64/base64.h>
  3. namespace NScUtils {
  4. void CopyField(const NSc::TValue& from, NSc::TValue& to) {
  5. to = from;
  6. }
  7. } // namespace NScUtils
  8. void TSerializer<NSc::TValue>::Save(IOutputStream* out, const NSc::TValue& v) {
  9. TString json = Base64Encode(v.ToJson());
  10. ::Save(out, json);
  11. }
  12. void TSerializer<NSc::TValue>::Load(IInputStream* in, NSc::TValue& v) {
  13. TString json;
  14. ::Load(in, json);
  15. json = Base64Decode(json);
  16. v = NSc::TValue::FromJsonThrow(json);
  17. }