forked from TrueCloudLab/neoneo-go
smartcontract: marshal Integer values to JSON-strings
It is done so in C# implementation, we better be as compatible as possible. Closes #770.
This commit is contained in:
parent
1e7b47ec05
commit
9666e99a17
1 changed files with 9 additions and 1 deletions
|
@ -63,8 +63,16 @@ func (p *Parameter) MarshalJSON() ([]byte, error) {
|
||||||
resultErr error
|
resultErr error
|
||||||
)
|
)
|
||||||
switch p.Type {
|
switch p.Type {
|
||||||
case BoolType, IntegerType, StringType, Hash256Type, Hash160Type:
|
case BoolType, StringType, Hash256Type, Hash160Type:
|
||||||
resultRawValue, resultErr = json.Marshal(p.Value)
|
resultRawValue, resultErr = json.Marshal(p.Value)
|
||||||
|
case IntegerType:
|
||||||
|
val, ok := p.Value.(int64)
|
||||||
|
if !ok {
|
||||||
|
resultErr = errors.New("invalid integer value")
|
||||||
|
break
|
||||||
|
}
|
||||||
|
valStr := strconv.FormatInt(val, 10)
|
||||||
|
resultRawValue = json.RawMessage(`"` + valStr + `"`)
|
||||||
case PublicKeyType, ByteArrayType, SignatureType:
|
case PublicKeyType, ByteArrayType, SignatureType:
|
||||||
if p.Value == nil {
|
if p.Value == nil {
|
||||||
resultRawValue = []byte("null")
|
resultRawValue = []byte("null")
|
||||||
|
|
Loading…
Reference in a new issue