2020-11-13 12:26:23 +00:00
|
|
|
package object
|
|
|
|
|
|
|
|
import (
|
|
|
|
object "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
|
|
|
|
"google.golang.org/protobuf/encoding/protojson"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (h *ShortHeader) MarshalJSON() ([]byte, error) {
|
|
|
|
return protojson.MarshalOptions{
|
|
|
|
EmitUnpopulated: true,
|
|
|
|
}.Marshal(
|
|
|
|
ShortHeaderToGRPCMessage(h),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *ShortHeader) UnmarshalJSON(data []byte) error {
|
|
|
|
msg := new(object.ShortHeader)
|
|
|
|
|
|
|
|
if err := protojson.Unmarshal(data, msg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*h = *ShortHeaderFromGRPCMessage(msg)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-11-13 12:31:15 +00:00
|
|
|
|
|
|
|
func (a *Attribute) MarshalJSON() ([]byte, error) {
|
|
|
|
return protojson.MarshalOptions{
|
|
|
|
EmitUnpopulated: true,
|
|
|
|
}.Marshal(
|
|
|
|
AttributeToGRPCMessage(a),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Attribute) UnmarshalJSON(data []byte) error {
|
|
|
|
msg := new(object.Header_Attribute)
|
|
|
|
|
|
|
|
if err := protojson.Unmarshal(data, msg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*a = *AttributeFromGRPCMessage(msg)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-11-13 12:34:13 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
}
|
2020-11-13 12:38:55 +00:00
|
|
|
|
|
|
|
func (h *Header) MarshalJSON() ([]byte, error) {
|
|
|
|
return protojson.MarshalOptions{
|
|
|
|
EmitUnpopulated: true,
|
|
|
|
}.Marshal(
|
|
|
|
HeaderToGRPCMessage(h),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *Header) UnmarshalJSON(data []byte) error {
|
|
|
|
msg := new(object.Header)
|
|
|
|
|
|
|
|
if err := protojson.Unmarshal(data, msg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*h = *HeaderFromGRPCMessage(msg)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-11-13 12:43:02 +00:00
|
|
|
|
|
|
|
func (h *HeaderWithSignature) MarshalJSON() ([]byte, error) {
|
|
|
|
return protojson.MarshalOptions{
|
|
|
|
EmitUnpopulated: true,
|
|
|
|
}.Marshal(
|
|
|
|
HeaderWithSignatureToGRPCMessage(h),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (h *HeaderWithSignature) UnmarshalJSON(data []byte) error {
|
|
|
|
msg := new(object.HeaderWithSignature)
|
|
|
|
|
|
|
|
if err := protojson.Unmarshal(data, msg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*h = *HeaderWithSignatureFromGRPCMessage(msg)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|
2020-11-13 12:51:27 +00:00
|
|
|
|
|
|
|
func (o *Object) MarshalJSON() ([]byte, error) {
|
|
|
|
return protojson.MarshalOptions{
|
|
|
|
EmitUnpopulated: true,
|
|
|
|
}.Marshal(
|
|
|
|
ObjectToGRPCMessage(o),
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (o *Object) UnmarshalJSON(data []byte) error {
|
|
|
|
msg := new(object.Object)
|
|
|
|
|
|
|
|
if err := protojson.Unmarshal(data, msg); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
*o = *ObjectFromGRPCMessage(msg)
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|