smartcontract: omit empty value in JSON for Interop/Any parameters

This commit is contained in:
Evgenii Stratonikov 2020-06-19 10:44:05 +03:00
parent 3a0be5ce28
commit b9e260a704

View file

@ -53,7 +53,7 @@ func NewParameter(t ParamType) Parameter {
type rawParameter struct { type rawParameter struct {
Type ParamType `json:"type"` Type ParamType `json:"type"`
Value json.RawMessage `json:"value"` Value json.RawMessage `json:"value,omitempty"`
} }
// MarshalJSON implements Marshaler interface. // MarshalJSON implements Marshaler interface.
@ -88,7 +88,7 @@ func (p *Parameter) MarshalJSON() ([]byte, error) {
ppair := p.Value.([]ParameterPair) ppair := p.Value.([]ParameterPair)
resultRawValue, resultErr = json.Marshal(ppair) resultRawValue, resultErr = json.Marshal(ppair)
case InteropInterfaceType, AnyType: case InteropInterfaceType, AnyType:
resultRawValue = []byte("null") resultRawValue = nil
default: default:
resultErr = errors.Errorf("Marshaller for type %s not implemented", p.Type) resultErr = errors.Errorf("Marshaller for type %s not implemented", p.Type)
} }