jsonparser

package module
v0.0.0-...-476bd9e Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

README

jsonparser

A simple json parser built using golang

Installation:

go get -u github.com/krishpranav/jsonparser

Installing the cli tool:

Cli tool:

$ jsonparser -d 1 < test.json

Tutorial:

package main

import (
	"fmt"
	"os"

	"github.com/krishpranav/jsonparser"
)

func main() {
	f, _ := os.Open("test.json")
	decoder := jsonparser.NewDecoder(f, 1)
	for mv := range decoder.Stream() {
		fmt.Printf("%v\n ", mv.Value)
	}
}

Author:

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type Decoder

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

func NewDecoder

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

func (*Decoder) EmitKV

func (d *Decoder) EmitKV() *Decoder

func (*Decoder) Err

func (d *Decoder) Err() error

func (*Decoder) ObjectAsKVS

func (d *Decoder) ObjectAsKVS() *Decoder

func (*Decoder) Pos

func (d *Decoder) Pos() int

func (*Decoder) Recursive

func (d *Decoder) Recursive() *Decoder

func (*Decoder) Stream

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

type DecoderError

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

func (DecoderError) Error

func (e DecoderError) Error() string

func (DecoderError) ReaderErr

func (e DecoderError) ReaderErr() error

type KV

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

type KVS

type KVS []KV

func (KVS) MarshalJSON

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

type MetaValue

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

type ValueType

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

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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