From 18ea3a6a4781b30a94479cdc19192655b992a8b3 Mon Sep 17 00:00:00 2001 From: Tzz Date: Thu, 29 Apr 2021 14:57:13 +0800 Subject: [PATCH] Fix: marshalJson error, when values contains map[interface{}]interface{} (#883) Co-authored-by: tzz --- config/reader.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config/reader.go b/config/reader.go index 44b762304..eb42fe8e6 100644 --- a/config/reader.go +++ b/config/reader.go @@ -74,7 +74,7 @@ func (r *reader) Value(path string) (Value, bool) { } func (r *reader) Source() ([]byte, error) { - return marshalJSON(r.values) + return marshalJSON(convertMap(r.values)) } func cloneMap(src map[string]interface{}) (map[string]interface{}, error) { @@ -103,8 +103,8 @@ func convertMap(src interface{}) interface{} { dst[fmt.Sprint(k)] = convertMap(v) } return dst - case []interface{} : - dst := make([]interface{},len(m)) + case []interface{}: + dst := make([]interface{}, len(m)) for k, v := range m { dst[k] = convertMap(v) }