forked from TrueCloudLab/frostfs-api-go
[#168] acl: Implement binary/JSON encoders/decoders on Record
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
9ddc4c1f48
commit
ae68790bbd
5 changed files with 106 additions and 5 deletions
|
@ -122,3 +122,23 @@ func (t *Target) UnmarshalJSON(data []byte) error {
|
|||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *Record) MarshalJSON() ([]byte, error) {
|
||||
return protojson.MarshalOptions{
|
||||
EmitUnpopulated: true,
|
||||
}.Marshal(
|
||||
RecordToGRPCMessage(r),
|
||||
)
|
||||
}
|
||||
|
||||
func (r *Record) UnmarshalJSON(data []byte) error {
|
||||
msg := new(acl.EACLRecord)
|
||||
|
||||
if err := protojson.Unmarshal(data, msg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
*r = *RecordFromGRPCMessage(msg)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue