code: func expandObject(node ast.Node, result reflect.Value) ast.Node {
  	item, ok := node.(*ast.ObjectItem)
  	if !ok {
  		return node
  	}
  
  	elemType := result.Type()
  
  	// our target type must be a struct
  	switch elemType.Kind() {
  	case reflect.Ptr:
  		switch elemType.Elem().Kind() {
  		case reflect.Struct:
  			//OK
  		default:
  			return node
  		}
  	case reflect.Struct:
  		//OK
  	default:
  		return node
  	}
  
  	// A list value will have a key and field name. If it had more fields,
  	// it wouldn't have been flattened.
  	if len(item.Keys) != 2 {
  		return node
  	}
  
  	keyToken := item.Keys[0].Token
  	item.Keys = item.Keys[1:]
  
  	// we need to un-flatten the ast enough to decode
  	newNode := &ast.ObjectItem{
  		Keys: []*ast.ObjectKey{
  			{
  				Token: keyToken,
  			},
  		},
  		Val: &ast.ObjectType{
  			List: &ast.ObjectList{
  				Items: []*ast.ObjectItem{item},
  			},
  		},
  	}
  
  	return newNode
  }
docs: // expandObject detects if an ambiguous JSON object was flattened to a List which
  // should be decoded into a struct, and expands the ast to properly deocode.