strictjson

package
Version: v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package strictjson is a helper package that provides unambiguous JSON parsing and helper functions for extracting JWS/JWT-specific data types from JSON.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDecodingFailed     = errors.New("decoding JSON failed")
	ErrDuplicateObjectKey = errors.New("duplicate object key encountered")
	ErrSuperfluousInput   = errors.New("unexpected token after JSON input")
	ErrUnexpectedFailure  = errors.New("json.Decoder returned an unexpected result")
)
View Source
var (
	ErrInvalidType         = errors.New("value has invalid type")
	ErrTimestampOutOfRange = errors.New("encountered an out-of-range timestamp")
)

Functions

func Decode

func Decode(source []byte) (interface{}, error)

Decode decodes the given JSON input, returning an error when encountering a duplicate object key It doesn't allow trailing input after the expected JSON input. This function has become necessary, as json.Unmarshal silently ignores duplicate keys. It uses the json.Decoder JSON parser.

func ToGenericMap

func ToGenericMap(value interface{}) (map[string]interface{}, error)

func ToString

func ToString(value interface{}) (string, error)

func ToStringList

func ToStringList(value interface{}) ([]string, error)

func ToTimestamp

func ToTimestamp(value interface{}) (time.Time, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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