// RenderJSONP renders JSONP result using encoding/json.Marshal
559288
func (c *Controller) RenderJSONP(callback string, o interface{}) Result {
	c.setStatusIfNil(http.StatusOK)

	return RenderJSONResult{o, callback}
}
961625
func RenderErrorJSON(c *gin.Context) {
	c.Next()

	if len(c.Errors) > 0 {
		errs := []error{}
		for _, err := range c.Errors {
			errs = append(errs, err)
		}

		c.JSON(
			http.StatusNotFound,
			errutil.NewErrors(errs...),
		)
	}
}
164829
func (c *Client) responseJSONMap(requestName string, resp *http.Response) (map[string]interface{}, error) {
	if resp.StatusCode != 200 {
		c.printf("After %s request, failed to JSON from response; status code is %d", requestName, resp.StatusCode)
		io.Copy(os.Stderr, resp.Body)
		return nil, fmt.Errorf("after %s request, HTTP response code is %d; no JSON to parse", requestName, resp.StatusCode)
	}
	jmap := make(map[string]interface{})
	if err := httputil.DecodeJSON(resp, &jmap); err != nil {
		return nil, err
	}
	return jmap, nil
}
298678
func (v *Value_Bytes) JSONRender() string {
	ret, err := json.Marshal(v.Bytes)
	if err != nil {
		panic(err)
	}
	return string(ret)
}
54082
func (c ContentSpec) RenderBytes(ctx *RenderingContext) []byte {
	switch ctx.PageFmt {
	default:
		return c.markdownRender(ctx)
	case "markdown":
		return c.markdownRender(ctx)
	case "asciidoc":
		return getAsciidocContent(ctx)
	case "mmark":
		return c.mmarkRender(ctx)
	case "rst":
		return getRstContent(ctx)
	case "org":
		return orgRender(ctx, c)
	case "pandoc":
		return getPandocContent(ctx)
	}
}
40539
func (p *WebPage) RenderBase64(format string) (string, error) {
	var resp struct {
		ReturnValue string `json:"returnValue"`
	}
	if err := p.ref.process.doJSON("POST", "/webpage/RenderBase64", map[string]interface{}{"ref": p.ref.id, "format": format}, &resp); err != nil {
		return "", err
	}
	return resp.ReturnValue, nil
}
1139962
func (t *Template) RenderBytes(context ...interface{}) ([]byte, error) {
	var b *bytes.Buffer
	err := t.Render(b, context...)
	return b.Bytes(), err
}
135364
func JSONPRender(status int, indent bool, callback string, data interface{}) *JSONP {
	return &JSONP{
		Indent:   indent,
		Callback: callback,
		Data:     data,
		Head: &Head{
			Status:  status,
			Content: ContentJSONP,
		},
	}
}
874204
func (j *LDSResult) MarshalJSONBuf(buf fflib.EncodingBuffer) error {
	if j == nil {
		buf.WriteString("null")
		return nil
	}
	var err error
	var obj []byte
	_ = obj
	_ = err
	buf.WriteString(`{"listeners":`)
	if j.Listeners != nil {
		buf.WriteString(`[`)
		for i, v := range j.Listeners {
			if i != 0 {
				buf.WriteString(`,`)
			}

			{

				if v == nil {
					buf.WriteString("null")
				} else {

					err = v.MarshalJSONBuf(buf)
					if err != nil {
						return err
					}

				}

			}
		}
		buf.WriteString(`]`)
	} else {
		buf.WriteString(`null`)
	}
	buf.WriteByte('}')
	return nil
}
649520
func jsonType(v interface{}) string {
	switch v.(type) {
	case nil:
		return "null"
	case bool:
		return "boolean"
	case json.Number, float64, int, int32, int64:
		return "number"
	case string:
		return "string"
	case []interface{}:
		return "array"
	case map[string]interface{}:
		return "object"
	}
	panic(InvalidJSONTypeError(fmt.Sprintf("%T", v)))
}
281339
func (results Results) MarshalJSON() ([]byte, error) {
	for _, result := range results {
		if result.ResultID() == "" {
			result.SetResultID(fmt.Sprintf("%d", &result))
		}

		if err := inferIQR(result); err != nil {
			return nil, err
		}
	}

	return json.Marshal([]Result(results))
}
954707
func (r *Render) Json(w http.ResponseWriter, status int, v interface{}) error {
	var (
		data []byte
		err  error
	)
	if r.opt.IndentJson {
		data, err = json.MarshalIndent(v, "", "  ")
		data = append(data, '\n')
	} else {
		data, err = json.Marshal(v)
	}
	if err != nil {
		return err
	}
	w.Header().Set("Content-Type", kContentJson+kContentCharset)
	w.WriteHeader(status)
	_, err = w.Write(data)
	return err
}
679808
func (r AsciiJSON) Render(w http.ResponseWriter) (err error) {
	r.WriteContentType(w)
	ret, err := json.Marshal(r.Data)
	if err != nil {
		return err
	}

	var buffer bytes.Buffer
	for _, r := range string(ret) {
		cvt := string(r)
		if r >= 128 {
			cvt = fmt.Sprintf("\\u%04x", int64(r))
		}
		buffer.WriteString(cvt)
	}

	_, err = w.Write(buffer.Bytes())
	return err
}
425078
func (r *Response) MarshalJSON() ([]byte, error) {
	return []byte(r.res), r.err
}
373868
func (ctx *Context) JSONP(code int, callback string, val interface{}) error {
	buf, err := json.Marshal(val)
	if err != nil {
		return err
	}
	return ctx.JSONPBlob(code, callback, buf)
}
671035
func (c *Controller) RenderJSON(o interface{}) Result {
	c.setStatusIfNil(http.StatusOK)

	return RenderJSONResult{o, ""}
}
888063
func RenderErrorFromMap(errors map[string]interface{}) string {
	buf := new(bytes.Buffer)

	for cond, condErrs := range errors {
		fmt.Fprintf(buf, " %s:", cond)
		for _, err := range condErrs.([]interface{}) {
			fmt.Fprintf(buf, " %s,", err.(string))
		}

	}

	return buf.String()
}