node_io.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #pragma once
  2. #include "node.h"
  3. #include <library/cpp/yson/public.h>
  4. namespace NJson {
  5. class TJsonValue;
  6. } // namespace NJson
  7. namespace NYT {
  8. ////////////////////////////////////////////////////////////////////////////////
  9. // Parse TNode from string in YSON format
  10. TNode NodeFromYsonString(const TStringBuf input, ::NYson::EYsonType type = ::NYson::EYsonType::Node);
  11. // Serialize TNode to string in one of YSON formats with random order of maps' keys (don't use in tests)
  12. TString NodeToYsonString(const TNode& node, ::NYson::EYsonFormat format = ::NYson::EYsonFormat::Text);
  13. // Same as the latter, but maps' keys are sorted lexicographically (to be used in tests)
  14. TString NodeToCanonicalYsonString(const TNode& node, ::NYson::EYsonFormat format = ::NYson::EYsonFormat::Text);
  15. // Parse TNode from stream in YSON format
  16. TNode NodeFromYsonStream(IInputStream* input, ::NYson::EYsonType type = ::NYson::EYsonType::Node);
  17. // Serialize TNode to stream in one of YSON formats with random order of maps' keys (don't use in tests)
  18. void NodeToYsonStream(const TNode& node, IOutputStream* output, ::NYson::EYsonFormat format = ::NYson::EYsonFormat::Text);
  19. // Same as the latter, but maps' keys are sorted lexicographically (to be used in tests)
  20. void NodeToCanonicalYsonStream(const TNode& node, IOutputStream* output, ::NYson::EYsonFormat format = ::NYson::EYsonFormat::Text);
  21. // Parse TNode from string in JSON format
  22. TNode NodeFromJsonString(const TStringBuf input);
  23. bool TryNodeFromJsonString(const TStringBuf input, TNode& dst);
  24. // Convert TJsonValue to TNode
  25. TNode NodeFromJsonValue(const ::NJson::TJsonValue& input);
  26. ////////////////////////////////////////////////////////////////////////////////
  27. } // namespace NYT