json

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2022 License: MIT Imports: 6 Imported by: 0

README

json

Contains constants and functions for handling JSON data. Substation relies on https://github.com/tidwall/gjson for reading JSON and https://github.com/tidwall/sjson for writing JSON; all features related to reading and writing from those projects are supported, refer to their documentation for further detail.

Documentation

Index

Constants

View Source
const JSONInvalidData = errors.Error("JSONInvalidData")

JSONInvalidData is returned when JSON functions return invalid JSON.

View Source
const JSONSetRawInvalid = errors.Error("JSONSetRawInvalid")

JSONSetRawInvalid is returned when SetRaw receives an invalid input.

Variables

View Source
var Types = map[gjson.Type]string{
	0: "Null",
	1: "Boolean",
	2: "Number",
	3: "String",
	4: "Boolean",
	5: "JSON",
}

Types maps gjson.Type to strings.

Functions

func DeepEquals

func DeepEquals(s1, s2 []byte) (bool, error)

DeepEquals performs a deep equals comparison between two byte arrays.

func Delete

func Delete(json []byte, key string) (tmp []byte, err error)

Delete wraps sjson.DeleteBytes.

func Set

func Set(json []byte, key string, value interface{}) (tmp []byte, err error)

Set wraps sjson.SetBytes.

func SetRaw

func SetRaw(json []byte, key string, value interface{}) (tmp []byte, err error)

SetRaw wraps sjson.SetRawBytes.

func Unmarshal

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

Unmarshal wraps json.Unmarshal.

func Valid

func Valid(data []byte) bool

Valid wraps json.Valid.

Types

type Result

type Result = gjson.Result

Result wraps gjson.Result.

func Get

func Get(json []byte, key string) Result

Get wraps gjson.GetBytes.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL