Closed
Description
Describe the bug
When loading two providers that have a key which contains an array, the first array item is replaced completely and the contents are not merged.
To Reproduce
package configx
import (
stdjson "encoding/json"
"github.com/knadh/koanf"
"github.com/knadh/koanf/parsers/json"
"github.com/knadh/koanf/providers/rawbytes"
"testing"
)
func TestKoanfMergeArray(t *testing.T) {
k := koanf.NewWithConf(koanf.Conf{Delim: Delimiter, StrictMerge: true})
if err := k.Load(rawbytes.Provider([]byte(`{"foo":[{"id":"bar"}]}`)), json.Parser()); err != nil {
t.Fatal(err)
}
if err := k.Load(rawbytes.Provider([]byte(`{"foo":[{"key":"baz"}]}`)), json.Parser()); err != nil {
t.Fatal(err)
}
expected := `{"foo":[{"id":"bar","key":"baz"}]}`
out, _ := stdjson.Marshal(k.All())
if string(out) != expected {
t.Fatalf("Expected %s but got: %s", expected, out)
}
}
Returns:
Expected {"foo":[{"id":"bar","key":"baz"}]} but got: {"foo":[{"key":"baz"}]}
Expected behavior
Expected to receive:
{"foo":[{"id":"bar","key":"baz"}]}
Please provide the following information):
- OS: macOS
- Koanf Version 1.3.3
Activity