PrintJSON prints any value as indented (human-readable) JSON.
(v interface{})
| 507 | |
| 508 | // PrintJSON prints any value as indented (human-readable) JSON. |
| 509 | func PrintJSON(v interface{}) error { |
| 510 | enc := json.NewEncoder(os.Stdout) |
| 511 | enc.SetIndent("", " ") |
| 512 | return enc.Encode(v) |
| 513 | } |
| 514 | |
| 515 | // PrintJSONCompact prints any value as compact (no-indent) JSON — a single |
| 516 | // line plus trailing newline. Preferred for machine-consumed payloads where |
no test coverage detected