smartcontract: simplify Array JSON marshalling

This commit is contained in:
Roman Khimov 2020-03-31 00:27:58 +03:00
parent 3dbe549a61
commit 25201d480d

View file

@ -82,14 +82,7 @@ func (p *Parameter) MarshalJSON() ([]byte, error) {
resultRawValue, resultErr = json.Marshal(hex.EncodeToString(p.Value.([]byte))) resultRawValue, resultErr = json.Marshal(hex.EncodeToString(p.Value.([]byte)))
} }
case ArrayType: case ArrayType:
var value = make([]json.RawMessage, 0) var value = p.Value.([]Parameter)
for _, parameter := range p.Value.([]Parameter) {
rawValue, err := json.Marshal(&parameter)
if err != nil {
return nil, err
}
value = append(value, rawValue)
}
resultRawValue, resultErr = json.Marshal(value) resultRawValue, resultErr = json.Marshal(value)
case MapType: case MapType:
ppair := p.Value.([]ParameterPair) ppair := p.Value.([]ParameterPair)