package jsonutil
import "github.com/teamwork/utils/jsonutil"
Package jsonutil provides functions for working with JSON.
Index ¶
- func Indent(data []byte, v interface{}, prefix, indent string) ([]byte, error)
- func MustIndent(data []byte, v interface{}, prefix, indent string) []byte
- func MustMarshal(v interface{}) []byte
- func MustMarshalIndent(v interface{}, prefix, indent string) []byte
- func MustUnmarshal(data []byte, v interface{})
Functions ¶
func Indent ¶
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 ¶
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 ¶
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 ¶
- Version
- v1.0.0 (latest)
- Published
- Mar 14, 2022
- Platform
- linux/amd64
- Imports
- 1 packages
- Last checked
- 1 hour ago –
Tools for package owners.