package jsonutil

import "github.com/teamwork/utils/jsonutil"

Package jsonutil provides functions for working with JSON.

Index

Functions

func Indent

func Indent(data []byte, v interface{}, prefix, indent string) ([]byte, error)

Indent a json string by unmarshalling it and marshalling it with MarshalIndent.

The data will be unmarshalled in to v, which must be a pointer. Example:

Indent(`{"a": "b"}`, &map[string]string{}, "", "  ")

func MustIndent

func MustIndent(data []byte, v interface{}, prefix, indent string) []byte

MustIndent behaves like Indent but will panic on errors.

func MustMarshal

func MustMarshal(v interface{}) []byte

MustMarshal behaves like json.Marshal but will panic on errors.

func MustMarshalIndent

func MustMarshalIndent(v interface{}, prefix, indent string) []byte

MustMarshalIndent behaves like json.MarshalIndent but will panic on errors.

func MustUnmarshal

func MustUnmarshal(data []byte, v interface{})

MustUnmarshal behaves like json.Unmarshal but will panic on errors.

Source Files

jsonutil.go

Version
v1.0.0 (latest)
Published
Mar 14, 2022
Platform
linux/amd64
Imports
1 packages
Last checked
1 hour ago

Tools for package owners.