|
|
@@ -119,9 +119,10 @@ func Unmarshal(in []byte, out interface{}) (err error) {
|
|
|
// flow Marshal using a flow style (useful for structs,
|
|
|
// sequences and maps.
|
|
|
//
|
|
|
-// inline Inline the struct it's applied to, so its fields
|
|
|
-// are processed as if they were part of the outer
|
|
|
-// struct.
|
|
|
+// inline Inline the field, which must be a struct or a map,
|
|
|
+// causing all of its fields or keys to be processed as if
|
|
|
+// they were part of the outer struct. For maps, keys must
|
|
|
+// not conflict with the yaml keys of other struct fields.
|
|
|
//
|
|
|
// In addition, if the key is "-", the field is ignored.
|
|
|
//
|
|
|
@@ -255,15 +256,14 @@ func getStructInfo(st reflect.Type) (*structInfo, error) {
|
|
|
|
|
|
if inline {
|
|
|
switch field.Type.Kind() {
|
|
|
- // TODO: Implement support for inline maps.
|
|
|
- //case reflect.Map:
|
|
|
- // if inlineMap >= 0 {
|
|
|
- // return nil, errors.New("Multiple ,inline maps in struct " + st.String())
|
|
|
- // }
|
|
|
- // if field.Type.Key() != reflect.TypeOf("") {
|
|
|
- // return nil, errors.New("Option ,inline needs a map with string keys in struct " + st.String())
|
|
|
- // }
|
|
|
- // inlineMap = info.Num
|
|
|
+ case reflect.Map:
|
|
|
+ if inlineMap >= 0 {
|
|
|
+ return nil, errors.New("Multiple ,inline maps in struct " + st.String())
|
|
|
+ }
|
|
|
+ if field.Type.Key() != reflect.TypeOf("") {
|
|
|
+ return nil, errors.New("Option ,inline needs a map with string keys in struct " + st.String())
|
|
|
+ }
|
|
|
+ inlineMap = info.Num
|
|
|
case reflect.Struct:
|
|
|
sinfo, err := getStructInfo(field.Type)
|
|
|
if err != nil {
|