json_proto_converter.h 919 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #ifndef TESTING_LIBFUZZER_PROTO_JSON_PROTO_CONVERTER_H_
  5. #define TESTING_LIBFUZZER_PROTO_JSON_PROTO_CONVERTER_H_
  6. #include <sstream>
  7. #include <string>
  8. #include "testing/libfuzzer/proto/json.pb.h"
  9. namespace json_proto {
  10. class JsonProtoConverter {
  11. public:
  12. std::string Convert(const JsonValue& json_value);
  13. std::string Convert(const json_proto::JsonObject&);
  14. std::string Convert(const json_proto::ArrayValue&);
  15. private:
  16. std::stringstream data_;
  17. void AppendArray(const json_proto::ArrayValue&);
  18. void AppendNumber(const json_proto::NumberValue&);
  19. void AppendObject(const json_proto::JsonObject&);
  20. void AppendValue(const json_proto::JsonValue&);
  21. };
  22. } // namespace json_proto
  23. #endif // TESTING_LIBFUZZER_PROTO_JSON_PROTO_CONVERTER_H_