encoding/protojson: add random whitespaces in encoding output
This is meant to deter users from doing byte for byte comparison.
Change-Id: If005d2dc1eba45eaa4254171d2f247820db109e4
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/194037
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/encoding/protojson/encode.go b/encoding/protojson/encode.go
index 1662e40..5f383fe 100644
--- a/encoding/protojson/encode.go
+++ b/encoding/protojson/encode.go
@@ -20,6 +20,8 @@
)
// Marshal writes the given proto.Message in JSON format using default options.
+// Do not depend on the output of being stable. It may change over time across
+// different versions of the program.
func Marshal(m proto.Message) ([]byte, error) {
return MarshalOptions{}.Marshal(m)
}
@@ -71,7 +73,8 @@
}
// Marshal marshals the given proto.Message in the JSON format using options in
-// MarshalOptions.
+// MarshalOptions. Do not depend on the output being stable. It may change over
+// time across different versions of the program.
func (o MarshalOptions) Marshal(m proto.Message) ([]byte, error) {
var err error
o.encoder, err = json.NewEncoder(o.Indent)