Found that we are only defining MarshalJSON for the Regexp type for
references not for the direct object

Also took the time to simplify the json.Unmarshal usage in cli/config.go
This commit is contained in:
Kellen Fox 2017-05-08 11:25:25 -07:00
parent cb8b507e62
commit 6aece86ac1
2 changed files with 3 additions and 5 deletions

View File

@ -74,12 +74,10 @@ func fetchConfig() (Config, error) {
}
defer res.Body.Close()
decoder := json.NewDecoder(res.Body)
err = decoder.Decode(&configResponse)
err = json.NewDecoder(res.Body).Decode(&configResponse)
if err != nil {
panic(err)
return Config{}, err
return configResponse.Data, err
}
if configResponse.Status != "success" {

View File

@ -503,7 +503,7 @@ func (re *Regexp) UnmarshalJSON(data []byte) error {
}
// MarshalJSON implements the json.Marshaler interface.
func (re *Regexp) MarshalJSON() ([]byte, error) {
func (re Regexp) MarshalJSON() ([]byte, error) {
if re.Regexp != nil {
return json.Marshal(re.String())
}