jsonparser

package module
v0.0.0-...-7b438b1 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2023 License: MIT Imports: 6 Imported by: 0

README

Json parser

simple parser to transform json data as other format ie csv

usage

  • print data to stdout
cat file.json | jsonparser
  • save data to csv file ("result.csv") in current location
cat file.json | jsonparser --csv

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInputNotJson error = errors.New("input is not a json object")
)

Functions

func ToCsv

func ToCsv(dw DataWriter) error

func ToStdout

func ToStdout(w DataWriter)

func ToString

func ToString(v interface{}) string

Types

type DataWriter

type DataWriter interface {
	GetHeaders() []string
	GetRow() Row
	Next() bool
}

func ParseInput

func ParseInput(input []byte) (DataWriter, error)

type Multiple

type Multiple struct {
	Headers []string
	Rows    []Row
	// contains filtered or unexported fields
}

func NewMultiple

func NewMultiple() Multiple

func (Multiple) GetHeaders

func (m Multiple) GetHeaders() []string

func (*Multiple) GetRow

func (m *Multiple) GetRow() Row

func (*Multiple) Next

func (m *Multiple) Next() bool

type Row

type Row map[string]interface{}

type Single

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

func NewSingle

func NewSingle() Single

func (Single) GetHeaders

func (s Single) GetHeaders() []string

func (*Single) GetRow

func (s *Single) GetRow() Row

func (Single) Next

func (s Single) Next() bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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