// JSON jsonified stop heal message.
766317
func (s stopHealMessage) JSON() string {
	stopHealJSONBytes, e := json.MarshalIndent(s, "", " ")
	fatalIf(probe.NewError(e), "Unable to marshal into JSON.")

	return string(stopHealJSONBytes)
}
484683
func (t *Template) JSON() ([]byte, error) {

	j, err := json.MarshalIndent(t, "", "  ")
	if err != nil {
		return nil, err
	}

	return intrinsics.ProcessJSON(j, nil)

}
1017879
func (r *Request) JSON(data interface{}) *Request {
	r.Use(body.JSON(data))
	return r
}
561977
func (ctxt *Context) ServeJSON(data interface{}) {
	encoded, err := json.Marshal(data)
	if err != nil {
		panic(err)
	}
	ctxt.Header().Set("Content-Type", "application/json")
	ctxt.Write(encoded)
}
1096839
func (c *Context) AbortWithStatusJSON(code int, jsonObj interface{}) {
	c.Abort()
	c.JSON(code, jsonObj)
}
797937
func JSON(val otto.Value) string {
	vm := otto.New()
	vm.Set("value", val)
	res, _ := vm.Run(`JSON.stringify(value)`)
	return res.String()
}
648509
func (c *C) JSON(status int, v interface{}) {
	c.Writer.Header().Set(contentType, "application/json; charset=UTF-8")
	c.Writer.WriteHeader(status)
	if v == nil {
		return
	}

	buf := bufPool.Get()
	defer bufPool.Put(buf)

	if err := json.NewEncoder(buf).Encode(v); err != nil {
		panic(err)
	}

	c.Writer.Write(buf.Bytes())
}
463471
func (ahs *allHealState) PopHealStatusJSON(path string,
	clientToken string) ([]byte, APIErrorCode) {

	// fetch heal state for given path
	h, exists := ahs.getHealSequence(path)
	if !exists {
		// If there is no such heal sequence, return error.
		return nil, ErrHealNoSuchProcess
	}

	// Check if client-token is valid
	if clientToken != h.clientToken {
		return nil, ErrHealInvalidClientToken
	}

	// Take lock to access and update the heal-sequence
	h.currentStatus.updateLock.Lock()
	defer h.currentStatus.updateLock.Unlock()

	numItems := len(h.currentStatus.Items)

	// calculate index of most recently available heal result
	// record.
	lastResultIndex := h.lastSentResultIndex
	if numItems > 0 {
		lastResultIndex = h.currentStatus.Items[numItems-1].ResultIndex
	}

	// After sending status to client, and before relinquishing
	// the updateLock, reset Item to nil and record the result
	// index sent to the client.
	defer func(i int64) {
		h.lastSentResultIndex = i
		h.currentStatus.Items = nil
	}(lastResultIndex)

	jbytes, err := json.Marshal(h.currentStatus)
	if err != nil {
		logger.LogIf(h.ctx, err)
		return nil, ErrInternalError
	}

	return jbytes, ErrNone
}
1213226
func JSON(w io.Writer, status int, v interface{}) error {
	jMutex.Lock()
	defer jMutex.Unlock()
	return Renderer.JSON(w, status, v)
}
1318458
func (c *Client) SendJSON(data interface{}) (err error) {
	w, err := c.NextWriter(websocket.TextMessage)
	if err != nil {
		return err
	}
	if data != nil {
		codec.NewEncoder(w, &jh).Encode(data)
	}
	return w.Close()
}
504267
func (s *JSONSchema) JSON() ([]byte, error) {
	if s.Ref == "" {
		s.Schema = SchemaRef
	}
	return json.Marshal(s)
}
162500
func (c clearSessionMessage) JSON() string {
	clearSessionJSONBytes, e := json.MarshalIndent(c, "", " ")
	fatalIf(probe.NewError(e), "Unable to marshal into JSON.")

	return string(clearSessionJSONBytes)
}
845993
func (f *Request) Json(j interface{}) *Request {
	f.json = j
	f.jsonIsSet = true
	f.SetHeader("Content-type", "application/json")
	return f
}
68691
func (ctx *Context) JSON(v interface{}) error {
	ctx.SetContentType(jsonCT)
	b, err := ctx.ToJSON(v)
	if err != nil {
		return err
	}

	_, err = ctx.Write(b)
	return err
}
895913
func (r *Router) JSON(route string, handler interface{}) *Router {
	h := r.determineHandler(handler)
	r.GET(route, jsonHandler(h))

	return r
}
27998
func (hc HealthCheck) MarshalJSON() ([]byte, error) {
	jhc := struct {
		Script         string
		Timeout        float64
		Interval       float64
		Tolerance      int
		KillExitCodes  []int `json:",omitempty"`
		KillCountLimit int   `json:",omitempty"`
	}{
		Script:         hc.Script,
		Timeout:        hc.Timeout.Seconds(),
		Interval:       hc.Interval.Seconds(),
		Tolerance:      hc.Tolerance,
		KillCountLimit: hc.KillCountLimit,
		KillExitCodes:  hc.KillExitCodes,
	}
	return json.Marshal(jhc)
}
33508
func ReadJSON(resp *http.Response, out interface{}) error {
	defer resp.Body.Close()

	if resp.StatusCode >= 400 {
		body, err := ioutil.ReadAll(resp.Body)
		if err != nil {
			return err
		}

		return fmt.Errorf("StatusCode: %d, Body: %s", resp.StatusCode, body)
	}

	if out == nil {
		io.Copy(ioutil.Discard, resp.Body)
		return nil
	}

	decoder := json.NewDecoder(resp.Body)
	return decoder.Decode(out)
}