Simple util for to be `python -mjson.tool` replacement
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
358 B

  1. // command jsoon is like python -m json.tool
  2. package main
  3. import (
  4. "bytes"
  5. "encoding/json"
  6. "io/ioutil"
  7. "log"
  8. "os"
  9. )
  10. func main() {
  11. b, err := ioutil.ReadAll(os.Stdin)
  12. if err != nil {
  13. log.Fatal("problem reading stdin", err)
  14. }
  15. var out bytes.Buffer
  16. err = json.Indent(&out, b, "", "\t")
  17. if err != nil {
  18. log.Fatal(err)
  19. }
  20. out.WriteTo(os.Stdout)
  21. }