MCPcopy Create free account
hub / github.com/segmentio/encoding / ExampleIndent

Function ExampleIndent

json/golang_example_test.go:245–274  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

243}
244
245func ExampleIndent() {
246 type Road struct {
247 Name string
248 Number int
249 }
250 roads := []Road{
251 {"Diamond Fork", 29},
252 {"Sheep Creek", 51},
253 }
254
255 b, err := json.Marshal(roads)
256 if err != nil {
257 log.Fatal(err)
258 }
259
260 var out bytes.Buffer
261 json.Indent(&out, b, "=", "\t")
262 out.WriteTo(os.Stdout)
263 // Output:
264 // [
265 // = {
266 // = "Name": "Diamond Fork",
267 // = "Number": 29
268 // = },
269 // = {
270 // = "Name": "Sheep Creek",
271 // = "Number": 51
272 // = }
273 // =]
274}
275
276func ExampleMarshalIndent() {
277 data := map[string]int{

Callers

nothing calls this directly

Calls 1

MarshalMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…