code: func (c *unstructuredConverter) ToUnstructured(obj interface{}) (map[string]interface{}, error) {
  	var u map[string]interface{}
  	var err error
  	if unstr, ok := obj.(Unstructured); ok {
  		u = unstr.UnstructuredContent()
  	} else {
  		t := reflect.TypeOf(obj)
  		value := reflect.ValueOf(obj)
  		if t.Kind() != reflect.Ptr || value.IsNil() {
  			return nil, fmt.Errorf("ToUnstructured requires a non-nil pointer to an object, got %v", t)
  		}
  		u = map[string]interface{}{}
  		err = toUnstructured(value.Elem(), reflect.ValueOf(&u).Elem())
  	}
  	if c.mismatchDetection {
  		newUnstr := map[string]interface{}{}
  		newErr := toUnstructuredViaJSON(obj, &newUnstr)
  		if (err != nil) != (newErr != nil) {
  			klog.Fatalf("ToUnstructured unexpected error for %v: error: %v; newErr: %v", obj, err, newErr)
  		}
  		if err == nil && !c.comparison.DeepEqual(u, newUnstr) {
  			klog.Fatalf("ToUnstructured mismatch\nobj1: %#v\nobj2: %#v", u, newUnstr)
  		}
  	}
  	if err != nil {
  		return nil, err
  	}
  	return u, nil
  }
docs: // ToUnstructured converts an object into map[string]interface{} representation.
  // It uses encoding/json/Marshaler if object implements it or reflection if not.