improve GetenvJson

This commit is contained in:
Victor Vieux
2013-12-13 16:02:19 -08:00
parent 4b5ceb0f24
commit d5f5ecb658
3 changed files with 9 additions and 12 deletions
+2 -5
View File
@@ -77,15 +77,12 @@ func (env *Env) GetList(key string) []string {
return l
}
func (env *Env) GetJson(key string) interface{} {
func (env *Env) GetJson(key string, iface interface{}) error {
sval := env.Get(key)
if sval == "" {
return nil
}
var m interface{}
//Discard error on purpose
json.Unmarshal([]byte(sval), &m)
return m
return json.Unmarshal([]byte(sval), iface)
}
func (env *Env) SetJson(key string, value interface{}) error {
+2 -2
View File
@@ -126,8 +126,8 @@ func (job *Job) GetenvList(key string) []string {
return job.env.GetList(key)
}
func (job *Job) GetenvJson(key string) interface{} {
return job.env.GetJson(key)
func (job *Job) GetenvJson(key string, iface interface{}) error {
return job.env.GetJson(key, iface)
}
func (job *Job) SetenvJson(key string, value interface{}) error {