PrintJSON prints any value as indented (human-readable) JSON.
(v interface{})
| 418 | |
| 419 | // PrintJSON prints any value as indented (human-readable) JSON. |
| 420 | func PrintJSON(v interface{}) error { |
| 421 | enc := json.NewEncoder(os.Stdout) |
| 422 | enc.SetIndent("", " ") |
| 423 | return enc.Encode(v) |
| 424 | } |
| 425 | |
| 426 | // PrintJSONCompact prints any value as compact (no-indent) JSON — a single |
| 427 | // line plus trailing newline. Preferred for machine-consumed payloads where |
no test coverage detected