diff --git a/adl/rot13adl/example_test.go b/adl/rot13adl/example_test.go index 101939324c0b11d0489ac41b31ad0690f51c39ad..4cc458e3ca84af524dbd2bb18bf0e0e237e29828 100644 --- a/adl/rot13adl/example_test.go +++ b/adl/rot13adl/example_test.go @@ -7,7 +7,6 @@ import ( "strings" "github.com/ipfs/go-cid" - "github.com/polydawn/refmt/json" "github.com/ipld/go-ipld-prime" "github.com/ipld/go-ipld-prime/adl/rot13adl" @@ -25,7 +24,7 @@ func ExampleUnmarshallingToADL() { nb := rot13adl.Prototype.SubstrateRoot.NewBuilder() // Unmarshal -- using the substrate's nodebuilder just like you'd unmarshal with any other nodebuilder. - err := dagjson.Unmarshal(nb, json.NewDecoder(strings.NewReader(`"n pbby fgevat"`)), true) + err := dagjson.Decode(nb, strings.NewReader(`"n pbby fgevat"`)) fmt.Printf("unmarshal error: %v\n", err) // Use `Reify` to get the synthetic high-level view of the ADL data. @@ -52,7 +51,7 @@ func ExampleLoadingToADL() { nb := rot13adl.Prototype.SubstrateRoot.NewBuilder() // Unmarshal -- using the substrate's nodebuilder just like you'd unmarshal with any other nodebuilder. - err := dagjson.Unmarshal(nb, json.NewDecoder(strings.NewReader(`"n pbby fgevat"`)), true) + err := dagjson.Decode(nb, strings.NewReader(`"n pbby fgevat"`)) fmt.Printf("unmarshal error: %v\n", err) substrateNode := nb.Build() @@ -108,7 +107,7 @@ func ExampleCreatingViaADL() { // To marshal the ADL, just use marshal methods on its substrate as normal: var marshalBuffer bytes.Buffer - err := dagjson.Marshal(substrateNode, json.NewEncoder(&marshalBuffer, json.EncodeOptions{}), true) + err := dagjson.Encode(substrateNode, &marshalBuffer) fmt.Printf("marshalled: %v\n", marshalBuffer.String()) fmt.Printf("marshal error: %v\n", err) diff --git a/codec/dagjson/multicodec.go b/codec/dagjson/multicodec.go index 00defd47e26ed197306951543e65a27574723bef..2b8f413af34a18c125ba88c30de6146fb0b8e560 100644 --- a/codec/dagjson/multicodec.go +++ b/codec/dagjson/multicodec.go @@ -53,8 +53,5 @@ func Encode(n ipld.Node, w io.Writer) error { // Shell out directly to generic inspection path. // (There's not really any fastpaths of note for json.) // Write another function if you need to tune encoding options about whitespace. - return Marshal(n, json.NewEncoder(w, json.EncodeOptions{ - Line: nil, - Indent: nil, - }), true) + return Marshal(n, json.NewEncoder(w, json.EncodeOptions{}), true) } diff --git a/node/bindnode/example_test.go b/node/bindnode/example_test.go index 199d6cf9c23461c725727f28face13dbfc8669ee..34b1ad35447bf699d31a5b2170b557a3454fbd28 100644 --- a/node/bindnode/example_test.go +++ b/node/bindnode/example_test.go @@ -8,7 +8,6 @@ import ( "github.com/ipld/go-ipld-prime/fluent/qp" "github.com/ipld/go-ipld-prime/node/bindnode" "github.com/ipld/go-ipld-prime/schema" - refmtjson "github.com/polydawn/refmt/json" ) func ExampleWrap_withSchema() { @@ -40,7 +39,7 @@ func ExampleWrap_withSchema() { node := bindnode.Wrap(person, schemaType) nodeRepr := node.Representation() - dagjson.Marshal(nodeRepr, refmtjson.NewEncoder(os.Stdout, refmtjson.EncodeOptions{}), true) + dagjson.Encode(nodeRepr, os.Stdout) // Output: // {"Name":"Michael","Friends":["Sarah","Alex"]} @@ -76,7 +75,7 @@ func ExamplePrototype_onlySchema() { } nodeRepr := node.(schema.TypedNode).Representation() - dagjson.Marshal(nodeRepr, refmtjson.NewEncoder(os.Stdout, refmtjson.EncodeOptions{}), true) + dagjson.Encode(nodeRepr, os.Stdout) // Output: // {"Name":"Michael","Friends":["Sarah","Alex"]} diff --git a/node/tests/testcase.go b/node/tests/testcase.go index 25ee0e984f282983b22828251619275f290ce111..8072bd46b57ebabd84c43752d5a8223dcb560556 100644 --- a/node/tests/testcase.go +++ b/node/tests/testcase.go @@ -191,7 +191,7 @@ func (tcase testcase) Test(t *testing.T, np, npr ipld.NodePrototype) { func testUnmarshal(t *testing.T, np ipld.NodePrototype, data string, expectFail error) ipld.Node { t.Helper() nb := np.NewBuilder() - err := dagjson.Unmarshal(nb, json.NewDecoder(strings.NewReader(data)), true) + err := dagjson.Decode(nb, strings.NewReader(data)) switch { case expectFail == nil && err != nil: t.Fatalf("fixture parse failed: %s", err) diff --git a/schema/schema2/typesystem_test.go b/schema/schema2/typesystem_test.go index 8d245ab6a6077c85b06c1d78839a1e69768c2fcd..ce20022eb846d6721d5d2b993f332c92baec2e51 100644 --- a/schema/schema2/typesystem_test.go +++ b/schema/schema2/typesystem_test.go @@ -5,7 +5,6 @@ import ( "strings" "testing" - "github.com/polydawn/refmt/json" . "github.com/warpfork/go-wish" "github.com/ipld/go-ipld-prime/codec/dagjson" @@ -206,7 +205,7 @@ func testParse(t *testing.T, schemajson string, expectParseErr error, expectType func parseSchema(schemajson string) (schemadmt.Schema, error) { nb := schemadmt.Type.Schema__Repr.NewBuilder() - if err := dagjson.Unmarshal(nb, json.NewDecoder(strings.NewReader(schemajson)), true); err != nil { + if err := dagjson.Decode(nb, strings.NewReader(schemajson)); err != nil { return nil, err } return nb.Build().(schemadmt.Schema), nil