PrintJSON prints any value as indented (human-readable) JSON.
(v interface{})
| 439 | |
| 440 | // PrintJSON prints any value as indented (human-readable) JSON. |
| 441 | func PrintJSON(v interface{}) error { |
| 442 | enc := json.NewEncoder(os.Stdout) |
| 443 | enc.SetIndent("", " ") |
| 444 | return enc.Encode(v) |
| 445 | } |
| 446 | |
| 447 | // PrintJSONCompact prints any value as compact (no-indent) JSON — a single |
| 448 | // line plus trailing newline. Preferred for machine-consumed payloads where |
no test coverage detected