code: func (p *jsonPatcher) applyJSPatch(versionedJS []byte) (patchedJS []byte, retErr error) {
  	switch p.patchType {
  	case types.JSONPatchType:
  		patchObj, err := jsonpatch.DecodePatch(p.patchBytes)
  		if err != nil {
  			return nil, errors.NewBadRequest(err.Error())
  		}
  		if len(patchObj) > maxJSONPatchOperations {
  			return nil, errors.NewRequestEntityTooLargeError(
  				fmt.Sprintf("The allowed maximum operations in a JSON patch is %d, got %d",
  					maxJSONPatchOperations, len(patchObj)))
  		}
  		patchedJS, err := patchObj.Apply(versionedJS)
  		if err != nil {
  			return nil, errors.NewGenericServerResponse(http.StatusUnprocessableEntity, "", schema.GroupResource{}, "", err.Error(), 0, false)
  		}
  		return patchedJS, nil
  	case types.MergePatchType:
  		return jsonpatch.MergePatch(versionedJS, p.patchBytes)
  	default:
  		// only here as a safety net - go-restful filters content-type
  		return nil, fmt.Errorf("unknown Content-Type header for patch: %v", p.patchType)
  	}
  }
docs: // applyJSPatch applies the patch. Input and output objects must both have
  // the external version, since that is what the patch must have been constructed against.