yajson

package module
v0.0.0-...-6bb5737 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: MIT Imports: 9 Imported by: 0

README

yajson

Yet Another JSON unmarshaller. It is built at jscan, blazing fast JSON iterator, and uses own unsafe inserting into structures. Main difference between this and other JSON unmarshallers is, that it compiles a JSON parser for each model. So by that, we eliminate type-unsafety of default standard approach with json.Unmarshal(any), but also gain performance - instead of checking the passed object every time via reflect, we do this just once - when the parser is being initialized, after that we do fill attributes by their offsets. Moreover, instead of returning a pointer, we return a new instance of a model by value - this also brings us to the fair zero-allocations!

Documentation

Index

Constants

View Source
const (
	BufferSpaceMin = 1024
	BufferSpaceMax = 127 * 1024
)

Variables

View Source
var (
	ErrNoSpace      = errors.New("no space for values")
	ErrTypeMismatch = errors.New("JSON carries an entry with an incompatible type")
	ErrUnknownType  = errors.New("the type is not supported by yajson")
)

Functions

This section is empty.

Types

type JSON

type JSON[T any] struct {
	// contains filtered or unexported fields
}

func New

func New[T any]() *JSON[T]

New returns a JSON parser instance for one specific model, defined via the generic

func (*JSON[T]) Parse

func (j *JSON[T]) Parse(input string) (result T, err error)

Parse parses the passed JSON and stores the values into a new instance of the model

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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