forked from TrueCloudLab/neoneo-go
core: refactor transaction.Attribute unmarshalling
This commit is contained in:
parent
09b8b8de73
commit
a6579a05ac
1 changed files with 5 additions and 7 deletions
|
@ -81,21 +81,19 @@ func (attr *Attribute) UnmarshalJSON(data []byte) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
switch aj.Type {
|
switch aj.Type {
|
||||||
case "HighPriority":
|
case HighPriority.String():
|
||||||
attr.Type = HighPriority
|
attr.Type = HighPriority
|
||||||
case "OracleResponse":
|
return nil
|
||||||
|
case OracleResponseT.String():
|
||||||
attr.Type = OracleResponseT
|
attr.Type = OracleResponseT
|
||||||
// Note: because `type` field will not be present in any attribute
|
// Note: because `type` field will not be present in any attribute
|
||||||
// value, we can unmarshal the same data. The overhead is minimal.
|
// value, we can unmarshal the same data. The overhead is minimal.
|
||||||
attr.Value = new(OracleResponse)
|
attr.Value = new(OracleResponse)
|
||||||
return json.Unmarshal(data, attr.Value)
|
case NotValidBeforeT.String():
|
||||||
case "NotValidBefore":
|
|
||||||
attr.Type = NotValidBeforeT
|
attr.Type = NotValidBeforeT
|
||||||
attr.Value = new(NotValidBefore)
|
attr.Value = new(NotValidBefore)
|
||||||
return json.Unmarshal(data, attr.Value)
|
|
||||||
default:
|
default:
|
||||||
return errors.New("wrong Type")
|
return errors.New("wrong Type")
|
||||||
|
|
||||||
}
|
}
|
||||||
return nil
|
return json.Unmarshal(data, attr.Value)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue