aboutsummaryrefslogtreecommitdiffstats
path: root/swarm/api/uri.go
diff options
context:
space:
mode:
Diffstat (limited to 'swarm/api/uri.go')
-rw-r--r--swarm/api/uri.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/swarm/api/uri.go b/swarm/api/uri.go
index 14965e0d9..808517088 100644
--- a/swarm/api/uri.go
+++ b/swarm/api/uri.go
@@ -53,6 +53,19 @@ type URI struct {
Path string
}
+func (u *URI) MarshalJSON() (out []byte, err error) {
+ return []byte(`"` + u.String() + `"`), nil
+}
+
+func (u *URI) UnmarshalJSON(value []byte) error {
+ uri, err := Parse(string(value))
+ if err != nil {
+ return err
+ }
+ *u = *uri
+ return nil
+}
+
// Parse parses rawuri into a URI struct, where rawuri is expected to have one
// of the following formats:
//