()
| 243 | } |
| 244 | |
| 245 | func 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 | |
| 276 | func ExampleMarshalIndent() { |
| 277 | data := map[string]int{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…