pretty print addrbook json

This commit is contained in:
Jae Kwon
2014-07-15 21:53:39 -07:00
parent ac668d4d14
commit 1603d6f385

View File

@@ -305,11 +305,11 @@ func (a *AddrBook) saveToFile(filePath string) {
log.Error("Error opening file: ", filePath, err)
return
}
enc := json.NewEncoder(w)
defer w.Close()
err = enc.Encode(&aJSON)
jsonBytes, err := json.MarshalIndent(aJSON, "", "\t")
_, err = w.Write(jsonBytes)
if err != nil {
panic(err)
log.Error("Failed to save AddrBook to file %v: %v", filePath, err)
}
}