File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,6 +25,28 @@ func ExampleNewMarshaller_json() {
2525 // <nil>
2626}
2727
28+ func ExampleNewMarshaller_json_prettyprint () {
29+ var buf bytes.Buffer
30+ encoder := refmt .NewMarshaller (json.EncodeOptions {
31+ Line : []byte {'\n' },
32+ Indent : []byte {'\t' },
33+ }, & buf )
34+ err := encoder .Marshal (map [string ]interface {}{
35+ "x" : "a" ,
36+ "y" : 1 ,
37+ })
38+ fmt .Println (buf .String ())
39+ fmt .Printf ("%v\n " , err )
40+
41+ // Output:
42+ // {
43+ // "x": "a",
44+ // "y": 1
45+ // }
46+ //
47+ // <nil>
48+ }
49+
2850func ExampleNewMarshallerAtlased_autogeneratedAtlas () {
2951 type MyType struct {
3052 X string
Original file line number Diff line number Diff line change @@ -39,9 +39,9 @@ type Marshaller interface {
3939}
4040
4141func NewMarshaller (opts EncodeOptions , wr io.Writer ) Marshaller {
42- switch opts .(type ) {
42+ switch o2 := opts .(type ) {
4343 case json.EncodeOptions :
44- return json .NewMarshaller (wr )
44+ return json .NewMarshallerAtlased (wr , o2 , atlas . MustBuild () )
4545 case cbor.EncodeOptions :
4646 return cbor .NewMarshaller (wr )
4747 default :
You can’t perform that action at this time.
0 commit comments