...
1 package jwriter
2
3 import (
4 "fmt"
5 )
6
7 func ExampleObjectState_Name() {
8 myCustomMarshaler := func(w *Writer) {
9 subObject := w.Object()
10 subObject.Name("yes").Bool(true)
11 subObject.End()
12 }
13
14 w := NewWriter()
15
16 obj := w.Object()
17 myCustomMarshaler(obj.Name("subObject"))
18 obj.End()
19
20 fmt.Println(string(w.Bytes()))
21
22 }
23
24 func ExampleObjectState_Maybe() {
25 w := NewWriter()
26 obj := w.Object()
27 obj.Maybe("notPresent", false).Int(1)
28 obj.Maybe("present", true).Int(2)
29 obj.End()
30
31 fmt.Println(string(w.Bytes()))
32
33 }
34
View as plain text