Compare commits
7 Commits
gx/v0.7.19
...
gx/v0.7.22
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bd441bb43e | ||
|
|
10a4d040b4 | ||
|
|
d204c18f7a | ||
|
|
b41162260a | ||
|
|
9cb0b7bcae | ||
|
|
5b04f30433 | ||
|
|
078355866b |
@@ -1 +1 @@
|
|||||||
0.7.19: QmeSrf6pzut73u6zLQkRFQ3ygt3k6XFT2kjdYP8Tnkwwyg
|
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
|
// Note that this formatting comes from the IPLD specification
|
||||||
// (https://github.com/ipld/specs/tree/master/ipld)
|
// (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
|
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")
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
10
package.json
10
package.json
@@ -9,15 +9,15 @@
|
|||||||
"gxDependencies": [
|
"gxDependencies": [
|
||||||
{
|
{
|
||||||
"author": "whyrusleeping",
|
"author": "whyrusleeping",
|
||||||
"hash": "QmYeKnKpubCMRiq3PGZcTREErthbb5Q9cXsCoSkD9bjEBd",
|
"hash": "QmPnFwZ2JXKnXgMw8CdBPxn7FWh6LLdjUjxV1fKHuJnkr8",
|
||||||
"name": "go-multihash",
|
"name": "go-multihash",
|
||||||
"version": "1.0.6"
|
"version": "1.0.8"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"author": "whyrusleeping",
|
"author": "whyrusleeping",
|
||||||
"hash": "QmafgXF3u3QSWErQoZ2URmQp5PFG384htoE7J338nS2H7T",
|
"hash": "QmexBtiTTEwwn42Yi6ouKt6VqzpA6wjJgiW1oh9VfaRrup",
|
||||||
"name": "go-multibase",
|
"name": "go-multibase",
|
||||||
"version": "0.2.5"
|
"version": "0.2.6"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"gxVersion": "0.8.0",
|
"gxVersion": "0.8.0",
|
||||||
@@ -25,6 +25,6 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"name": "go-cid",
|
"name": "go-cid",
|
||||||
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
|
"releaseCmd": "git commit -a -m \"gx publish $VERSION\"",
|
||||||
"version": "0.7.19"
|
"version": "0.7.22"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user