Add proper JSON marshaling of config regexps. (#602)

This commit is contained in:
devnev 2017-01-17 10:50:54 +00:00 committed by stuart nelson
parent 5489644cbe
commit f2ba86e9d2
1 changed files with 9 additions and 0 deletions

View File

@ -22,6 +22,7 @@ import (
"strings" "strings"
"time" "time"
"encoding/json"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
) )
@ -481,3 +482,11 @@ func (re *Regexp) MarshalYAML() (interface{}, error) {
} }
return nil, nil return nil, nil
} }
// MarshalJSON implements the json.Marshaler interface.
func (re Regexp) MarshalJSON() ([]byte, error) {
if re.Regexp != nil {
return json.Marshal(re.String())
}
return nil, nil
}