jsonlint

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2023 License: MIT Imports: 4 Imported by: 1

README

JSON lint

Simple JSON linter. There are no advantages over any other linters. Made just for fun.

Usage

Good JSON:

src := `{"name":"John","age":31,"city":"New York"}`
_, err := jsonlint.ValidateStr(src)
assertNil(err)

Bad JSON:

src := `{"id":1,"name":"Foo","price":123,"tags":["Bar",,"Eek"],"stock":{"warehouse":300,"retail":20}}`
offset, err := jsonlint.ValidateStr(src)
assertEqual(err, jsonlint.ErrUnexpId)
assertEqual(offset, 47)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrEmptySrc     = errors.New("can't parse empty source")
	ErrUnparsedTail = errors.New("unparsed tail")
	ErrUnexpId      = errors.New("unexpected identifier")
	ErrUnexpEOF     = errors.New("unexpected end of file")
	ErrUnexpEOS     = errors.New("unexpected end of string")
)

Functions

func Validate

func Validate[T byteseq.Byteseq](x T) (offset int, err error)

Validate source bytes.

Types

This section is empty.

Jump to

Keyboard shortcuts

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