everyone should get free ice cream

This commit is contained in:
Jeff Carr 2024-11-15 19:53:06 -06:00
parent c158f8a58c
commit 1fc481620f
1 changed files with 13 additions and 1 deletions

View File

@ -6,6 +6,7 @@ package zoopb
import (
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/encoding/prototext"
"google.golang.org/protobuf/proto"
// "google.golang.org/protobuf/proto"
)
@ -21,7 +22,7 @@ func (p *Packages) FormatTEXT() string {
return prototext.Format(p)
}
// marshal
// marshal json
func (p *Packages) MarshalJSON() ([]byte, error) {
return protojson.Marshal(p)
}
@ -30,3 +31,14 @@ func (p *Packages) MarshalJSON() ([]byte, error) {
func (p *Packages) UnmarshalJSON(data []byte) error {
return protojson.Unmarshal(data, p)
}
// marshal to wire
func (p *Packages) Marshal() ([]byte, error) {
return proto.Marshal(p)
}
// unmarshal from wire
func (p *Packages) Unmarshal(data []byte) error {
return proto.Unmarshal(data, p)
}