forked from TrueCloudLab/frostfs-api-go
[#168] refs: Implement binary/JSON encoders/decoders on ContainerID
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
7289ff6c64
commit
c0f3ac51d4
6 changed files with 103 additions and 4 deletions
|
@ -44,3 +44,23 @@ func (o *ObjectID) UnmarshalJSON(data []byte) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *ContainerID) MarshalJSON() ([]byte, error) {
|
||||
return protojson.MarshalOptions{
|
||||
EmitUnpopulated: true,
|
||||
}.Marshal(
|
||||
ContainerIDToGRPCMessage(c),
|
||||
)
|
||||
}
|
||||
|
||||
func (c *ContainerID) UnmarshalJSON(data []byte) error {
|
||||
msg := new(refs.ContainerID)
|
||||
|
||||
if err := protojson.Unmarshal(data, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*c = *ContainerIDFromGRPCMessage(msg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue