forked from TrueCloudLab/neoneo-go
rpc: convert null
value to a defaultT
Right now we convert it is unmarshaler into a float64(0) so an error is supressed.
This commit is contained in:
parent
bed08d3f89
commit
d550e539ba
2 changed files with 9 additions and 1 deletions
|
@ -243,6 +243,11 @@ func (p *Param) UnmarshalJSON(data []byte) error {
|
||||||
{ArrayT, &[]Param{}},
|
{ArrayT, &[]Param{}},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if bytes.Equal(data, []byte("null")) {
|
||||||
|
p.Type = defaultT
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
for _, cur := range attempts {
|
for _, cur := range attempts {
|
||||||
r := bytes.NewReader(data)
|
r := bytes.NewReader(data)
|
||||||
jd := json.NewDecoder(r)
|
jd := json.NewDecoder(r)
|
||||||
|
|
|
@ -14,7 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestParam_UnmarshalJSON(t *testing.T) {
|
func TestParam_UnmarshalJSON(t *testing.T) {
|
||||||
msg := `["str1", 123, ["str2", 3], [{"type": "String", "value": "jajaja"}],
|
msg := `["str1", 123, null, ["str2", 3], [{"type": "String", "value": "jajaja"}],
|
||||||
{"primary": 1},
|
{"primary": 1},
|
||||||
{"sender": "f84d6a337fbc3d3a201d41da99e86b479e7a2554"},
|
{"sender": "f84d6a337fbc3d3a201d41da99e86b479e7a2554"},
|
||||||
{"cosigner": "f84d6a337fbc3d3a201d41da99e86b479e7a2554"},
|
{"cosigner": "f84d6a337fbc3d3a201d41da99e86b479e7a2554"},
|
||||||
|
@ -36,6 +36,9 @@ func TestParam_UnmarshalJSON(t *testing.T) {
|
||||||
Type: NumberT,
|
Type: NumberT,
|
||||||
Value: 123,
|
Value: 123,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Type: defaultT,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Type: ArrayT,
|
Type: ArrayT,
|
||||||
Value: []Param{
|
Value: []Param{
|
||||||
|
|
Loading…
Reference in a new issue