mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
accounts: implement json unmarshalling of url
This commit is contained in:
parent
ec83d9d0ab
commit
69a96f8fef
1 changed files with 16 additions and 0 deletions
|
|
@ -74,6 +74,22 @@ func (u URL) MarshalJSON() ([]byte, error) {
|
||||||
return json.Marshal(u.String())
|
return json.Marshal(u.String())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// MarshalJSON parses url.
|
||||||
|
func (u *URL) UnmarshalJSON(input []byte) error {
|
||||||
|
var textUrl string
|
||||||
|
err := json.Unmarshal(input, &textUrl)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
url, err := parseURL(textUrl)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
u.Scheme = url.Scheme
|
||||||
|
u.Path = url.Path
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Cmp compares x and y and returns:
|
// Cmp compares x and y and returns:
|
||||||
//
|
//
|
||||||
// -1 if x < y
|
// -1 if x < y
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue