// JSONRender returns a rendering of this uint as JSON, e.g. go value 100
// renders as `"100"`.
//
// Unsigns render as strings to avoid encoding issues in JSON, which only
// supports double-precision floating point numbers.
776632
func (v *Value_Uint) JSONRender() string {
	num := strconv.FormatUint(v.Uint, 10)
	if v.Uint < (1 << 53) {
		return num
	}
	return fmt.Sprintf(`"%s"`, num)
}
109825
func (s Slice) JSONString(options ...DumperOptions) (string, error) {
	buf := &bytes.Buffer{}
	var opt *DumperOptions
	if len(options) > 0 {
		opt = &options[0]
	}
	d := NewDumper(buf, opt)
	if err := d.Append(s); err != nil {
		return "", WithStack(err)
	}
	return buf.String(), nil
}
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
}
920125
func (pdfg *PDFGenerator) ToJSON() ([]byte, error) {

	jpdf := &jsonPDFGenerator{
		TOC:            pdfg.TOC,
		Cover:          pdfg.Cover,
		GlobalOptions:  pdfg.globalOptions,
		OutlineOptions: pdfg.outlineOptions,
	}

	for _, p := range pdfg.pages {
		jp := jsonPage{
			InputFile: p.InputFile(),
		}
		switch tp := p.(type) {
		case *Page:
			jp.PageOptions = tp.PageOptions
		case *PageReader:
			jp.PageOptions = tp.PageOptions
		}
		if p.Reader() != nil {
			buf, err := ioutil.ReadAll(p.Reader())
			if err != nil {
				return nil, err
			}
			jp.Base64PageData = base64.StdEncoding.EncodeToString(buf)
		}
		jpdf.Pages = append(jpdf.Pages, jp)
	}
	return json.Marshal(jpdf)
}
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
}
574394
func (r ProtoBuf) Render(w http.ResponseWriter) error {
	r.WriteContentType(w)

	bytes, err := proto.Marshal(r.Data.(proto.Message))
	if err != nil {
		return err
	}

	_, err = w.Write(bytes)
	return err
}
867128
func Render(v string, ctx *Context) (string, error) {
	return (&I{Value: v}).Render(ctx)
}
1055591
func RenderJSON(w http.ResponseWriter, status int, data interface{}) error {
	return Render(w, true).JSON(status, data)
}
191508
func (p *WebPage) Render(filename, format string, quality int) error {
	req := map[string]interface{}{"ref": p.ref.id, "filename": filename, "format": format, "quality": quality}
	return p.ref.process.doJSON("POST", "/webpage/Render", req, nil)
}
137555
func (r IndentedJSON) Render(w http.ResponseWriter) error {
	r.WriteContentType(w)
	jsonBytes, err := json.MarshalIndent(r.Data, "", "    ")
	if err != nil {
		return err
	}
	_, err = w.Write(jsonBytes)
	return err
}
107821
func NewRenderRenderer(dir string, extensions []string, funcs []template.FuncMap, dev bool) *RenderRenderer {
	opts := render.Options{
		Directory:     dir,
		Extensions:    extensions,
		Funcs:         funcs,
		IsDevelopment: dev,
	}
	return &RenderRenderer{r: render.New(opts)}
}
821357
func renderInteger(f float64) string {
	if f > math.Nextafter(float64(math.MaxInt64), 0) {
		return fmt.Sprintf("%d", int64(math.MaxInt64))
	}
	if f < math.Nextafter(float64(math.MinInt64), 0) {
		return fmt.Sprintf("%d", int64(math.MinInt64))
	}
	return fmt.Sprintf("%d", int64(f))
}
775171
func (s *Server) JSON(w http.ResponseWriter, status int, data interface{}) {
	w.Header().Set("Content-Type", "application/json")
	w.WriteHeader(status)
	json.NewEncoder(w).Encode(data)
}
281025
func (t *Tabulate) Render(format ...interface{}) string {
	var lines []string

	// If headers are set use them, otherwise pop the first row
	if len(t.Headers) < 1 && len(t.Data) > 1 {
		t.Headers, t.Data = t.Data[0].Elements, t.Data[1:]
	}

	// Use the format that was passed as parameter, otherwise
	// use the format defined in the struct
	if len(format) > 0 {
		t.TableFormat = TableFormats[format[0].(string)]
	}

	// If Wrap Strings is set to True,then break up the string to multiple cells
	if t.WrapStrings {
		t.Data = t.wrapCellData()
	}

	// Check if Data is present
	if len(t.Data) < 1 {
		return ""
	}

	if len(t.Headers) < len(t.Data[0].Elements) {
		diff := len(t.Data[0].Elements) - len(t.Headers)
		padded_header := make([]string, diff)
		for _, e := range t.Headers {
			padded_header = append(padded_header, e)
		}
		t.Headers = padded_header
	}

	// Get Column widths for all columns
	cols := t.getWidths(t.Headers, t.Data)

	padded_widths := make([]int, len(cols))
	for i, _ := range padded_widths {
		padded_widths[i] = cols[i] + MIN_PADDING*t.TableFormat.Padding
	}

	// Calculate total width of the table
	totalWidth := len(t.TableFormat.DataRow.sep) * (len(cols) - 1) // Include all but the final separator
	for _, w := range padded_widths {
		totalWidth += w
	}

	// Start appending lines
	if len(t.Title) > 0 {
		if !inSlice("aboveTitle", t.HideLines) {
			lines = append(lines, t.buildLine(padded_widths, cols, t.TableFormat.LineTop))
		}
		savedAlign := t.Align
		if len(t.TitleAlign) > 0 {
			t.SetAlign(t.TitleAlign) // Temporary replace alignment with the title alignment
		}
		lines = append(lines, t.buildRow([]string{t.Title}, []int{totalWidth}, nil, t.TableFormat.TitleRow))
		t.SetAlign(savedAlign)
	}

	// Append top line if not hidden
	if !inSlice("top", t.HideLines) {
		lines = append(lines, t.buildLine(padded_widths, cols, t.TableFormat.LineTop))
	}

	// Add Header
	lines = append(lines, t.buildRow(t.padRow(t.Headers, t.TableFormat.Padding), padded_widths, cols, t.TableFormat.HeaderRow))

	// Add Line Below Header if not hidden
	if !inSlice("belowheader", t.HideLines) {
		lines = append(lines, t.buildLine(padded_widths, cols, t.TableFormat.LineBelowHeader))
	}

	// Add Data Rows
	for index, element := range t.Data {
		lines = append(lines, t.buildRow(t.padRow(element.Elements, t.TableFormat.Padding), padded_widths, cols, t.TableFormat.DataRow))
		if index < len(t.Data)-1 {
			if element.Continuos != true && !inSlice("betweenLine", t.HideLines) {
				lines = append(lines, t.buildLine(padded_widths, cols, t.TableFormat.LineBetweenRows))
			}
		}
	}

	if !inSlice("bottomLine", t.HideLines) {
		lines = append(lines, t.buildLine(padded_widths, cols, t.TableFormat.LineBottom))
	}

	// Join lines
	var buffer bytes.Buffer
	for _, line := range lines {
		buffer.WriteString(line + "\n")
	}

	return buffer.String()
}
181668
func jsonParseInteger(s []byte) (n uint64, neg, badSyntax, overflow bool) {
	const maxUint64 = (1<<64 - 1)
	const cutoff = maxUint64/10 + 1

	if len(s) == 0 { // bounds-check-elimination
		// treat empty string as zero value
		// badSyntax = true
		return
	}
	switch s[0] {
	case '+':
		s = s[1:]
	case '-':
		s = s[1:]
		neg = true
	}
	for _, c := range s {
		if c < '0' || c > '9' {
			badSyntax = true
			return
		}
		// unsigned integers don't overflow well on multiplication, so check cutoff here
		// e.g. (maxUint64-5)*10 doesn't overflow well ...
		if n >= cutoff {
			overflow = true
			return
		}
		n *= 10
		n1 := n + uint64(c-'0')
		if n1 < n || n1 > maxUint64 {
			overflow = true
			return
		}
		n = n1
	}
	return
}
705337
func (t *TemplateRenderable) Render(_ ...string) string {
	return string(t.cache.Bytes())
}
563056
func RenderErrorJSON(render render.Render, status int, err error, errs ...error) {
	errConcat := append([]error{err}, errs...)
	errjson, err := errutil.NewJSON(errutil.NewErrorsSkip(1, errConcat...))
	errutil.Trace(err)
	reserr := responseError{
		Status:    status,
		ErrorJSON: errjson,
	}
	render.JSON(status, reserr)
}