//BindJSON binds json body to interface
768733
func (e *ExchangeMessage) BindJSON(v interface{}) error {
	switch t := e.body.(type) {
	case string:
		return json.Unmarshal([]byte(t), &v)
	case []byte:
		return json.Unmarshal(t, &v)
	case error:
		return t
	default:
		return errors.New("Invalid datatype")
	}
}
976524
func (s policyRules) JSON() string {
	policyJSONBytes, e := json.MarshalIndent(s, "", " ")
	fatalIf(probe.NewError(e), "Unable to marshal into JSON.")
	return string(policyJSONBytes)
}
561670
func (b *binder) Bind(ctx Context, i interface{}) (err error) {
	if ctx.Request().Method == http.MethodGet {
		err = b.unmarshal(ctx, i)
		return
	}

	if ctx.Request().ContentLength == 0 {
		return errors.New("request body is empty")
	}

	ct := ctx.ContentType()
	switch {
	case strings.HasPrefix(ct, "application/x-www-form-urlencoded"):
		return b.unmarshal(ctx, i)
	case strings.HasPrefix(ct, "multipart/form-data"):
		return b.unmarshal(ctx, i)
	case strings.HasPrefix(ct, "application/json"):
		return json.NewDecoder(ctx.Request().Body).Decode(i)
	case strings.HasPrefix(ct, "application/xml"):
		return xml.NewDecoder(ctx.Request().Body).Decode(i)
	default:
		return errors.New("unsupported content type")
	}
}
723433
func (s *IndicesPutMappingService) BodyJson(mapping map[string]interface{}) *IndicesPutMappingService {
	s.bodyJson = mapping
	return s
}
245804
func bindMap(params *Params, name string, typ reflect.Type) reflect.Value {
	var (
		keyType   = typ.Key()
		valueType = typ.Elem()
		resultPtr = reflect.New(reflect.MapOf(keyType, valueType))
		result    = resultPtr.Elem()
	)
	result.Set(reflect.MakeMap(typ))
	if params.JSON != nil {
		// Try to inject the response as a json into the created result
		if err := json.Unmarshal(params.JSON, resultPtr.Interface()); err != nil {
			binderLog.Warn("bindMap: Unable to unmarshal request", "name", name, "error", err)
		}
		return result
	}

	for paramName := range params.Values {
		// The paramName string must start with the value in the "name" parameter,
		// otherwise there is no way the parameter is part of the map
		if !strings.HasPrefix(paramName, name) {
			continue
		}

		suffix := paramName[len(name)+1:]
		fieldName := nextKey(suffix)
		if fieldName != "" {
			fieldName = fieldName[:len(fieldName)-1]
		}
		if !strings.HasPrefix(paramName, name+"["+fieldName+"]") {
			continue
		}

		result.SetMapIndex(BindValue(fieldName, keyType), Bind(params, name+"["+fieldName+"]", valueType))
	}
	return result
}
1224533
func (b *binder) Bind(binding *v1.Binding) error {
	klog.V(3).Infof("Attempting to bind %v to %v", binding.Name, binding.Target.Name)
	return b.Client.CoreV1().Pods(binding.Namespace).Bind(binding)
}
675671
func (c *xContext) JSON(i interface{}, codes ...int) (err error) {
	var b []byte
	if c.echo.Debug() {
		b, err = json.MarshalIndent(i, "", "  ")
	} else {
		b, err = json.Marshal(i)
	}
	if err != nil {
		return err
	}
	return c.JSONBlob(b, codes...)
}
987014
func (db *SQLDB) getJSON(JSON interface{}) ([]byte, error) {
	if JSON != nil {
		return json.Marshal(JSON)
	}
	return json.Marshal("")
}
353830
func (c *Context) BindTexture(target int, texture *js.Object) {
	c.Call("bindTexture", target, texture)
}
533975
func (c *Context) DecodeJSON(v interface{}) error {
	defer c.Request().Body.Close()
	return json.NewDecoder(c.Request().Body).Decode(v)
}
1300516
func WriteJSON(w http.ResponseWriter, obj interface{}) error {
	writeContentType(w, jsonContentType)
	jsonBytes, err := json.Marshal(obj)
	if err != nil {
		return err
	}
	_, err = w.Write(jsonBytes)
	return err
}
848509
func (c *C) InsertJSON(obj interface{}) error {
	b, err := json.Marshal(obj)
	if err != nil {
		return err
	}
	return c.Insert(b)
}
711954
func (c *ctx) JSON(data interface{}) error {
	b, err := json.Marshal(data)
	if err != nil {
		return err
	}
	return c.raw(b, contentTypeJSON)
}
948357
func bindTopicTypeJava(kind abi.Type) string {
	bound := bindTypeJava(kind)
	if bound == "String" || bound == "Bytes" {
		bound = "Hash"
	}
	return bound
}
1125249
func PublishJSON(ctx context.Context, topic string, obj interface{}) *PublishResult {
	pr := &PublishResult{Ready: make(chan struct{})}
	go func() {
		err := client.Publish(ctx, topic, obj, true)
		pr.Err = err
		close(pr.Ready)
	}()
	return pr
}
127356
func (c Context) RawJSON(key string, b []byte) Context {
	c.l.context = appendJSON(enc.AppendKey(c.l.context, key), b)
	return c
}
1017879
func (r *Request) JSON(data interface{}) *Request {
	r.Use(body.JSON(data))
	return r
}