frostfs-api-go-pogpp/v2/audit/json.go
Leonard Lyubich 9986a4ecd1 [#233] Implement data audit result type with basic methods
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
2020-12-25 16:20:34 +03:00

26 lines
531 B
Go

package audit
import (
audit "github.com/nspcc-dev/neofs-api-go/v2/audit/grpc"
"google.golang.org/protobuf/encoding/protojson"
)
func (a *DataAuditResult) MarshalJSON() ([]byte, error) {
return protojson.MarshalOptions{
EmitUnpopulated: true,
}.Marshal(
DataAuditResultToGRPCMessage(a),
)
}
func (a *DataAuditResult) UnmarshalJSON(data []byte) error {
msg := new(audit.DataAuditResult)
if err := protojson.Unmarshal(data, msg); err != nil {
return err
}
*a = *DataAuditResultFromGRPCMessage(msg)
return nil
}