jstream: github.com/bcicen/jstream Index | Files

package jstream

import "github.com/bcicen/jstream"

Index

Package Files

decoder.go errors.go scanner.go scratch.go

Variables

var (
    ErrSyntax        = DecoderError{/* contains filtered or unexported fields */}
    ErrUnexpectedEOF = DecoderError{/* contains filtered or unexported fields */}
)

Predefined errors

type Decoder Uses

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

Decoder wraps an io.Reader to provide incremental decoding of JSON values

func NewDecoder Uses

func NewDecoder(r io.Reader, emitDepth int) *Decoder

NewDecoder creates new Decoder to read JSON values at the provided emitDepth from the provider io.Reader. If emitDepth is < 0, values at every depth will be emitted.

func (*Decoder) EmitKV Uses

func (d *Decoder) EmitKV() *Decoder

EmitKV enables emitting a jstream.KV struct when the items(s) parsed at configured emit depth are within a JSON object. By default, only the object values are emitted.

func (*Decoder) Err Uses

func (d *Decoder) Err() error

Err returns the most recent decoder error if any, or nil

func (*Decoder) ObjectAsKVS Uses

func (d *Decoder) ObjectAsKVS() *Decoder

ObjectAsKVS - by default JSON returns map[string]interface{} this is usually fine in most cases, but when you need to preserve the input order its not a right data structure. To preserve input order please use this option.

func (*Decoder) Pos Uses

func (d *Decoder) Pos() int

Pos returns the number of bytes consumed from the underlying reader

func (*Decoder) Recursive Uses

func (d *Decoder) Recursive() *Decoder

Recursive enables emitting all values at a depth higher than the configured emit depth; e.g. if an array is found at emit depth, all values within the array are emitted to the stream, then the array containing those values is emitted.

func (*Decoder) Stream Uses

func (d *Decoder) Stream() chan *MetaValue

Stream begins decoding from the underlying reader and returns a streaming MetaValue channel for JSON values at the configured emitDepth.

type DecoderError Uses

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

func (DecoderError) Error Uses

func (e DecoderError) Error() string

func (DecoderError) ReaderErr Uses

func (e DecoderError) ReaderErr() error

type KV Uses

type KV struct {
    Key   string      `json:"key"`
    Value interface{} `json:"value"`
}

KV contains a key and value pair parsed from a decoded object

type KVS Uses

type KVS []KV

KVS - represents key values in an JSON object

func (KVS) MarshalJSON Uses

func (kvs KVS) MarshalJSON() ([]byte, error)

MarshalJSON - implements converting a KVS datastructure into a JSON object with multiple keys and values.

type MetaValue Uses

type MetaValue struct {
    Offset    int
    Length    int
    Depth     int
    Value     interface{}
    ValueType ValueType
}

MetaValue wraps a decoded interface value with the document position and depth at which the value was parsed

type ValueType Uses

type ValueType int

ValueType - defines the type of each JSON value

const (
    Unknown ValueType = iota
    Null
    String
    Number
    Boolean
    Array
    Object
)

Different types of JSON value

Package jstream imports 8 packages (graph) and is imported by 16 packages. Updated 2020-03-31. Refresh now. Tools for package owners.