Compare commits
6 Commits
gx/v0.7.20
...
gx/v0.7.22
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd441bb43e | ||
|
|
10a4d040b4 | ||
|
|
d204c18f7a | ||
|
|
b41162260a | ||
|
|
9cb0b7bcae | ||
|
|
5b04f30433 |
@@ -1 +1 @@
|
||||
0.7.20: QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY
|
||||
0.7.22: QmYVNvtQkeZ6AKSwDrjQTs432QtL6umrrK41EBq3cu7iSP
|
||||
|
||||
2
cid.go
2
cid.go
@@ -410,7 +410,7 @@ func (c *Cid) UnmarshalJSON(b []byte) error {
|
||||
//
|
||||
// Note that this formatting comes from the IPLD specification
|
||||
// (https://github.com/ipld/specs/tree/master/ipld)
|
||||
func (c *Cid) MarshalJSON() ([]byte, error) {
|
||||
func (c Cid) MarshalJSON() ([]byte, error) {
|
||||
return []byte(fmt.Sprintf("{\"/\":\"%s\"}", c.String())), nil
|
||||
}
|
||||
|
||||
|
||||
29
cid_test.go
29
cid_test.go
@@ -383,3 +383,32 @@ func TestFromJson(t *testing.T) {
|
||||
t.Fatal("json parsing failed")
|
||||
}
|
||||
}
|
||||
|
||||
func TestJsonRoundTrip(t *testing.T) {
|
||||
exp, err := Decode("zb2rhhFAEMepUBbGyP1k8tGfz7BSciKXP6GHuUeUsJBaK6cqG")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
// Verify it works for a *Cid.
|
||||
enc, err := json.Marshal(exp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var actual Cid
|
||||
err = json.Unmarshal(enc, &actual)
|
||||
if !exp.Equals(&actual) {
|
||||
t.Fatal("cids not equal for *Cid")
|
||||
}
|
||||
|
||||
// Verify it works for a Cid.
|
||||
enc, err = json.Marshal(*exp)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var actual2 Cid
|
||||
err = json.Unmarshal(enc, &actual2)
|
||||
if !exp.Equals(&actual2) {
|
||||
t.Fatal("cids not equal for Cid")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
"gxDependencies": [
|
||||
{
|
||||
"author": "whyrusleeping",
|
||||
"hash": "QmZyZDi491cCNTLfAhwcaDii2Kg4pwKRkhqQzURGDvY6ua",
|
||||
"hash": "QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8",
|
||||
"name": "go-multihash",
|
||||
"version": "1.0.7"
|
||||
"version": "1.0.8"
|
||||
},
|
||||
{
|
||||
"author": "whyrusleeping",
|
||||
@@ -25,6 +25,6 @@
|
||||
"license": "MIT",
|
||||
"name": "go-cid",
|
||||
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
|
||||
"version": "0.7.20"
|
||||
"version": "0.7.22"
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user