config: Add a default json encoder.

This commit is contained in:
Daniel Theophanes
2013-09-21 08:59:37 -07:00
parent 1c0d39018c
commit 90eac82f69
+6
View File
@@ -20,6 +20,12 @@ func DecodeJsonConfig(r io.Reader, v interface{}) error {
return d.Decode(v)
}
// Simple JSON based configuration encoder.
func EncodeJsonConfig(w io.Writer, v interface{}) error {
e := json.NewEncoder(w)
return e.Encode(v)
}
// Return a configuration file path. If baseName is empty,
// then the current executable name without the extension
// is used. If postfix is empty then DefaultPostfix is used.