From 9b4b533f2feafca6d6fb9568b868b990bde6a2ec Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Sat, 19 Mar 2016 16:58:15 -0700 Subject: [PATCH] Pretty print JSON --- cmd/tendermint/gen_validator.go | 4 ++-- cmd/tendermint/show_validator.go | 5 ++--- types/genesis.go | 2 +- types/priv_validator.go | 2 +- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/cmd/tendermint/gen_validator.go b/cmd/tendermint/gen_validator.go index 344d61bf8..37f0e2997 100644 --- a/cmd/tendermint/gen_validator.go +++ b/cmd/tendermint/gen_validator.go @@ -3,14 +3,14 @@ package main import ( "fmt" - "github.com/tendermint/tendermint/types" "github.com/tendermint/go-wire" + "github.com/tendermint/tendermint/types" ) func gen_validator() { privValidator := types.GenPrivValidator() - privValidatorJSONBytes := wire.JSONBytes(privValidator) + privValidatorJSONBytes := wire.JSONBytesPretty(privValidator) fmt.Printf(`Generated a new validator! Paste the following JSON into your %v file diff --git a/cmd/tendermint/show_validator.go b/cmd/tendermint/show_validator.go index 52082b003..e6c68e31f 100644 --- a/cmd/tendermint/show_validator.go +++ b/cmd/tendermint/show_validator.go @@ -1,15 +1,14 @@ - package main import ( "fmt" - "github.com/tendermint/tendermint/types" "github.com/tendermint/go-wire" + "github.com/tendermint/tendermint/types" ) func show_validator() { privValidatorFile := config.GetString("priv_validator_file") privValidator := types.LoadOrGenPrivValidator(privValidatorFile) - fmt.Println(string(wire.JSONBytes(privValidator.PubKey))) + fmt.Println(string(wire.JSONBytesPretty(privValidator.PubKey))) } diff --git a/types/genesis.go b/types/genesis.go index 2c5fc8274..9c81bc2d2 100644 --- a/types/genesis.go +++ b/types/genesis.go @@ -31,7 +31,7 @@ type GenesisDoc struct { // Utility method for saving GenensisDoc as JSON file. func (genDoc *GenesisDoc) SaveAs(file string) error { - genDocBytes := wire.JSONBytes(genDoc) + genDocBytes := wire.JSONBytesPretty(genDoc) return WriteFile(file, genDocBytes, 0644) } diff --git a/types/priv_validator.go b/types/priv_validator.go index 69f7527e6..30fdfff76 100644 --- a/types/priv_validator.go +++ b/types/priv_validator.go @@ -141,7 +141,7 @@ func (privVal *PrivValidator) save() { if privVal.filePath == "" { PanicSanity("Cannot save PrivValidator: filePath not set") } - jsonBytes := wire.JSONBytes(privVal) + jsonBytes := wire.JSONBytesPretty(privVal) err := WriteFileAtomic(privVal.filePath, jsonBytes, 0600) if err != nil { // `@; BOOM!!!