forked from TrueCloudLab/frostfs-api-go
[#168] object: Implement binary/JSON encoders/decoders on SplitHeader
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
0caff85fb7
commit
78374caa41
4 changed files with 45 additions and 5 deletions
|
@ -44,3 +44,23 @@ func (a *Attribute) UnmarshalJSON(data []byte) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (h *SplitHeader) MarshalJSON() ([]byte, error) {
|
||||
return protojson.MarshalOptions{
|
||||
EmitUnpopulated: true,
|
||||
}.Marshal(
|
||||
SplitHeaderToGRPCMessage(h),
|
||||
)
|
||||
}
|
||||
|
||||
func (h *SplitHeader) UnmarshalJSON(data []byte) error {
|
||||
msg := new(object.Header_Split)
|
||||
|
||||
if err := protojson.Unmarshal(data, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*h = *SplitHeaderFromGRPCMessage(msg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue