@@ -11,7 +11,6 @@ import (
1111 "github.com/pelletier/go-toml/v2"
1212 v2dasel "github.com/tomwright/dasel/v2"
1313 "github.com/tomwright/dasel/v3"
14- yamlv2 "gopkg.in/yaml.v2"
1514 "gopkg.in/yaml.v3"
1615)
1716
@@ -66,7 +65,7 @@ func NewView(path string) (*View, error) {
6665 return nil , err
6766 }
6867
69- err = yamlv2 .Unmarshal (data , & view )
68+ err = yaml .Unmarshal (data , & view )
7069 if err != nil {
7170 return nil , err
7271 }
@@ -348,38 +347,10 @@ func fileToValue(f *File) (DaselValue, []scalarPos, error) {
348347 return nil , nil , errors .New ("unsupported file type" )
349348 }
350349
351- value , isMap := normalize ( raw ) .(map [string ]any )
350+ value , isMap := raw .(map [string ]any )
352351 if ! isMap {
353352 return nil , nil , errors .New ("document root is not an object" )
354353 }
355354
356355 return value , scalars , nil
357356}
358-
359- // normalize recursively converts map[interface{}]interface{} (produced by
360- // gopkg.in/yaml.v2) to map[string]any so that Dasel v3 can traverse the
361- // document without choking on interface{} map keys.
362- func normalize (v any ) any {
363- switch val := v .(type ) {
364- case map [interface {}]interface {}:
365- out := make (map [string ]any , len (val ))
366- for k , v := range val {
367- out [fmt .Sprintf ("%v" , k )] = normalize (v )
368- }
369- return out
370- case map [string ]any :
371- out := make (map [string ]any , len (val ))
372- for k , v := range val {
373- out [k ] = normalize (v )
374- }
375- return out
376- case []any :
377- out := make ([]any , len (val ))
378- for i , v := range val {
379- out [i ] = normalize (v )
380- }
381- return out
382- default :
383- return val
384- }
385- }
0 commit comments