From 31999a3f95d8ec9f93b56b0966e2895c5205da53 Mon Sep 17 00:00:00 2001 From: Lizan Zhou Date: Wed, 22 Jun 2016 11:46:10 -0700 Subject: Add JsonParseOptions to ignore unknown fields - add JsonParseOptions for JsonToBinaryString allow unknown fields - rename current JsonOptions to JsonPrintOptions --- src/google/protobuf/util/internal/proto_writer.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/google/protobuf/util/internal/proto_writer.h') diff --git a/src/google/protobuf/util/internal/proto_writer.h b/src/google/protobuf/util/internal/proto_writer.h index 957565e7..6f276065 100644 --- a/src/google/protobuf/util/internal/proto_writer.h +++ b/src/google/protobuf/util/internal/proto_writer.h @@ -142,6 +142,10 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { const TypeInfo* typeinfo() { return typeinfo_; } + void set_ignore_unknown_fields(bool ignore_unknown_fields) { + ignore_unknown_fields_ = ignore_unknown_fields; + } + protected: class LIBPROTOBUF_EXPORT ProtoElement : public BaseElement, public LocationTrackerInterface { public: @@ -240,7 +244,8 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { // Lookup the field in the current element. Looks in the base descriptor // and in any extension. This will report an error if the field cannot be - // found or if multiple matching extensions are found. + // found when ignore_unknown_names_ is false or if multiple matching + // extensions are found. const google::protobuf::Field* Lookup(StringPiece name); // Lookup the field type in the type descriptor. Returns NULL if the type @@ -293,6 +298,9 @@ class LIBPROTOBUF_EXPORT ProtoWriter : public StructuredObjectWriter { // Indicates whether we finished writing root message completely. bool done_; + // If true, don't report unknown field names to the listener. + bool ignore_unknown_fields_; + // Variable for internal state processing: // element_ : the current element. // size_insert_: sizes of nested messages. -- cgit v1.2.3