// Custom Unmarshal JSON to validate request body when creating a new index.
358522
func (p *postIndexRequest) UnmarshalJSON(b []byte) error {

	// m is an overflow map used to capture additional, unexpected keys.
	m := make(map[string]interface{})
	if err := json.Unmarshal(b, &m); err != nil {
		return errors.Wrap(err, "unmarshalling unexpected values")
	}

	validIndexOptions := getValidOptions(pilosa.IndexOptions{})
	err := validateOptions(m, validIndexOptions)
	if err != nil {
		return err
	}
	// Unmarshal expected values.
	_p := _postIndexRequest{
		Options: pilosa.IndexOptions{
			Keys:           false,
			TrackExistence: true,
		},
	}
	if err := json.Unmarshal(b, &_p); err != nil {
		return errors.Wrap(err, "unmarshalling expected values")
	}

	p.Options = _p.Options

	return nil
}
485547
func (u *PropertiesSearchError) UnmarshalJSON(body []byte) error {
	type wrap struct {
		dropbox.Tagged
		// PropertyGroupLookup : has no documentation (yet)
		PropertyGroupLookup json.RawMessage `json:"property_group_lookup,omitempty"`
	}
	var w wrap
	var err error
	if err = json.Unmarshal(body, &w); err != nil {
		return err
	}
	u.Tag = w.Tag
	switch u.Tag {
	case "property_group_lookup":
		err = json.Unmarshal(w.PropertyGroupLookup, &u.PropertyGroupLookup)

		if err != nil {
			return err
		}
	}
	return nil
}
1248478
func (pTypeDef *TimestampTest) UnmarshalJSON(b []byte) error {
	var r rawTimestampTest
	err := json.Unmarshal(b, &r)
	if err == nil {
		o := TimestampTest(r)
		*pTypeDef = o
		err = pTypeDef.Validate()
	}
	return err
}
708850
func (im *IndexMappingImpl) UnmarshalJSON(data []byte) error {

	var tmp map[string]json.RawMessage
	err := json.Unmarshal(data, &tmp)
	if err != nil {
		return err
	}

	// set defaults for fields which might have been omitted
	im.cache = registry.NewCache()
	im.CustomAnalysis = newCustomAnalysis()
	im.TypeField = defaultTypeField
	im.DefaultType = defaultType
	im.DefaultAnalyzer = defaultAnalyzer
	im.DefaultDateTimeParser = defaultDateTimeParser
	im.DefaultField = defaultField
	im.DefaultMapping = NewDocumentMapping()
	im.TypeMapping = make(map[string]*DocumentMapping)
	im.StoreDynamic = StoreDynamic
	im.IndexDynamic = IndexDynamic
	im.DocValuesDynamic = DocValuesDynamic

	var invalidKeys []string
	for k, v := range tmp {
		switch k {
		case "analysis":
			err := json.Unmarshal(v, &im.CustomAnalysis)
			if err != nil {
				return err
			}
		case "type_field":
			err := json.Unmarshal(v, &im.TypeField)
			if err != nil {
				return err
			}
		case "default_type":
			err := json.Unmarshal(v, &im.DefaultType)
			if err != nil {
				return err
			}
		case "default_analyzer":
			err := json.Unmarshal(v, &im.DefaultAnalyzer)
			if err != nil {
				return err
			}
		case "default_datetime_parser":
			err := json.Unmarshal(v, &im.DefaultDateTimeParser)
			if err != nil {
				return err
			}
		case "default_field":
			err := json.Unmarshal(v, &im.DefaultField)
			if err != nil {
				return err
			}
		case "default_mapping":
			err := json.Unmarshal(v, &im.DefaultMapping)
			if err != nil {
				return err
			}
		case "types":
			err := json.Unmarshal(v, &im.TypeMapping)
			if err != nil {
				return err
			}
		case "store_dynamic":
			err := json.Unmarshal(v, &im.StoreDynamic)
			if err != nil {
				return err
			}
		case "index_dynamic":
			err := json.Unmarshal(v, &im.IndexDynamic)
			if err != nil {
				return err
			}
		case "docvalues_dynamic":
			err := json.Unmarshal(v, &im.DocValuesDynamic)
			if err != nil {
				return err
			}
		default:
			invalidKeys = append(invalidKeys, k)
		}
	}

	if MappingJSONStrict && len(invalidKeys) > 0 {
		return fmt.Errorf("index mapping contains invalid keys: %v", invalidKeys)
	}

	err = im.CustomAnalysis.registerAll(im)
	if err != nil {
		return err
	}

	return nil
}
453294
func (resp *OpenIDTokenResponse) UnmarshalJSON(data []byte) (err error) {
	o2 := openIDTokenResponse{}
	if err = json.Unmarshal(data, &o2); err == nil {
		*resp = OpenIDTokenResponse(o2)
		now := time.Now()
		resp.Expiration = now.Add(time.Duration(resp.ExpiresIn) * time.Second)
		return
	}
	return
}
908858
func (v *MediumPayload) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjsonB0500db0DecodeGithubComFrancoispqtGojayBenchmarks(&r, v)
	return r.Error()
}
630065
func (self *ArrayTypeDef) UnmarshalJSON(b []byte) error {
	var m rawArrayTypeDef
	err := json.Unmarshal(b, &m)
	if err == nil {
		o := ArrayTypeDef(m)
		*self = *((&o).Init())
		err = self.Validate()
	}
	return err
}
1127591
func Unmarshal(r *request.Request) {
	if r.DataFilled() {
		v := reflect.Indirect(reflect.ValueOf(r.Data))
		unmarshalBody(r, v)
	}
}
731159
func (o *ElasticIP) UnmarshalJSON(data []byte) error {
	var jsonName string
	if err := json.Unmarshal(data, &jsonName); err == nil {
		o.Name = &jsonName
		return nil
	}

	var r realElasticIP
	if err := json.Unmarshal(data, &r); err != nil {
		return err
	}
	*o = ElasticIP(r)
	return nil
}
319467
func (r *OrderReturn) UnmarshalJSON(data []byte) error {
	if id, ok := ParseID(data); ok {
		r.ID = id
		return nil
	}

	type orderReturn OrderReturn
	var v orderReturn
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}

	*r = OrderReturn(v)
	return nil
}
1218436
func (x *Questionnaire) UnmarshalJSON(data []byte) (err error) {
	x2 := questionnaire{}
	if err = json.Unmarshal(data, &x2); err == nil {
		if x2.Contained != nil {
			for i := range x2.Contained {
				x2.Contained[i] = MapToResource(x2.Contained[i], true)
			}
		}
		*x = Questionnaire(x2)
		return x.checkResourceType()
	}
	return
}
941744
func (a *PssAddress) UnmarshalJSON(input []byte) error {
	b, err := hexutil.Decode(string(input[1 : len(input)-1]))
	if err != nil {
		return err
	}
	for _, bb := range b {
		*a = append(*a, bb)
	}
	return nil
}
287420
func Unmarshal(req *request.Request) {
	defer req.HTTPResponse.Body.Close()
	if req.DataFilled() {
		err := jsonutil.UnmarshalJSON(req.Data, req.HTTPResponse.Body)
		if err != nil {
			req.Error = awserr.NewRequestFailure(
				awserr.New("SerializationError", "failed decoding JSON RPC response", err),
				req.HTTPResponse.StatusCode,
				req.RequestID,
			)
		}
	}
	return
}
617402
func (u *PropertiesSearchMode) UnmarshalJSON(body []byte) error {
	type wrap struct {
		dropbox.Tagged
	}
	var w wrap
	var err error
	if err = json.Unmarshal(body, &w); err != nil {
		return err
	}
	u.Tag = w.Tag
	switch u.Tag {
	case "field_name":
		err = json.Unmarshal(body, &u.FieldName)

		if err != nil {
			return err
		}
	}
	return nil
}
218736
func (s *Subscription) UnmarshalJSON(data []byte) error {
	if id, ok := ParseID(data); ok {
		s.ID = id
		return nil
	}

	type subscription Subscription
	var v subscription
	if err := json.Unmarshal(data, &v); err != nil {
		return err
	}

	*s = Subscription(v)
	return nil
}
158835
func unmarshal(req *http.Request, pbReq proto.Message) (string, error) {
	var mime string
	alt := req.URL.Query().Get("alt")
	if alt == "" {
		alt = req.Header.Get("Content-Type")
	}
	switch alt {
	case "json", mimeJSON:
		mime = mimeJSON
	case "proto", mimeProto:
		mime = mimeProto
	default:
		return mime, errors.New("invalid interchange format")
	}

	switch req.Header.Get("Content-Type") {
	case mimeJSON:
		if err := jsonpb.Unmarshal(req.Body, pbReq); err != nil {
			return mime, err
		}
	case mimeProto:
		body, err := ioutil.ReadAll(req.Body)
		if err != nil {
			return mime, err
		}
		if err := proto.Unmarshal(body, pbReq); err != nil {
			return mime, err
		}
	}
	return mime, nil
}
329235
func (v *bulkIndexRequestCommand) UnmarshalJSON(data []byte) error {
	r := jlexer.Lexer{Data: data}
	easyjson9de0fcbfDecodeGithubComOlivereElastic1(&r, v)
	return r.Error()
}