From bf8ac8c5e158f8d25acb4894960edc8281a266ad Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Wed, 14 Jul 2021 12:26:06 +1000 Subject: [PATCH] Remove pretty-printing --- codec/dagjson/multicodec.go | 4 ++-- codec/dagjson/roundtripBytes_test.go | 21 ++------------------- codec/dagjson/roundtrip_test.go | 18 +----------------- 3 files changed, 5 insertions(+), 38 deletions(-) diff --git a/codec/dagjson/multicodec.go b/codec/dagjson/multicodec.go index 7a035d2..00defd4 100644 --- a/codec/dagjson/multicodec.go +++ b/codec/dagjson/multicodec.go @@ -54,7 +54,7 @@ func Encode(n ipld.Node, w io.Writer) error { // (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: []byte{'\n'}, - Indent: []byte{'\t'}, + Line: nil, + Indent: nil, }), true) } diff --git a/codec/dagjson/roundtripBytes_test.go b/codec/dagjson/roundtripBytes_test.go index df4e9f6..ccbef3e 100644 --- a/codec/dagjson/roundtripBytes_test.go +++ b/codec/dagjson/roundtripBytes_test.go @@ -15,15 +15,7 @@ var byteNode = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent na.AssembleEntry("plain").AssignString("olde string") na.AssembleEntry("bytes").AssignBytes([]byte("deadbeef")) }) -var byteSerial = `{ - "plain": "olde string", - "bytes": { - "/": { - "bytes": "ZGVhZGJlZWY=" - } - } -} -` +var byteSerial = `{"plain":"olde string","bytes":{"/":{"bytes":"ZGVhZGJlZWY="}}}` func TestRoundtripBytes(t *testing.T) { t.Run("encoding", func(t *testing.T) { @@ -46,16 +38,7 @@ var encapsulatedNode = fluent.MustBuildMap(basicnode.Prototype__Map{}, 1, func(n sa.AssembleEntry("bytes").AssignBytes([]byte("deadbeef")) }) }) -var encapsulatedSerial = `{ - "/": { - "bytes": { - "/": { - "bytes": "ZGVhZGJlZWY=" - } - } - } -} -` +var encapsulatedSerial = `{"/":{"bytes":{"/":{"bytes":"ZGVhZGJlZWY="}}}}` func TestEncapsulatedBytes(t *testing.T) { t.Run("encoding", func(t *testing.T) { diff --git a/codec/dagjson/roundtrip_test.go b/codec/dagjson/roundtrip_test.go index 757fc6c..1889680 100644 --- a/codec/dagjson/roundtrip_test.go +++ b/codec/dagjson/roundtrip_test.go @@ -27,23 +27,7 @@ var n = fluent.MustBuildMap(basicnode.Prototype__Map{}, 4, func(na fluent.MapAss }) }) }) -var serial = `{ - "plain": "olde string", - "map": { - "one": 1, - "two": 2 - }, - "list": [ - "three", - "four" - ], - "nested": { - "deeper": [ - "things" - ] - } -} -` +var serial = `{"plain":"olde string","map":{"one":1,"two":2},"list":["three","four"],"nested":{"deeper":["things"]}}` func TestRoundtrip(t *testing.T) { t.Run("encoding", func(t *testing.T) { -- GitLab