json5

package module
v0.0.0-...-468be6a Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: MIT Imports: 10 Imported by: 0

README

barney.ci/go-json5

This library implements a parser that supports a subset of the JSON5 specification.

Features

It actually works. I'm not even kidding, I tried alternatives and they all failed on real-world parsing scenarios when trying to deal with comments.

Everything in the JSON5 specification is supported except for Infinity and NaN. This is because this library translates a JSON5 document to JSON, where both values are non-representable. A proper parser needs to be implemented in order to support that use-case.

Usage

go get barney.ci/go-json5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDecoder

func NewDecoder(rd io.Reader) *json.Decoder

func Unmarshal

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

Types

type LexingError

type LexingError struct {
	Line   int
	Column int
	Err    error
}

func (*LexingError) Error

func (e *LexingError) Error() string

func (*LexingError) Unwrap

func (e *LexingError) Unwrap() error

type Reader

type Reader struct {
	// contains filtered or unexported fields
}

Reader translates on the fly JSON5 documents to equivalent JSON.

Note that the result is not guaranteed to be valid JSON; the reader should be fed to an actual json decoder for validation.

func NewReader

func NewReader(rd io.Reader) *Reader

func (*Reader) Read

func (r *Reader) Read(buf []byte) (int, error)

Jump to

Keyboard shortcuts

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