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