tabify

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSON

func JSON(j *jsonmap.Json, opt ...Option) ([]*jsonmap.Json, error)

JSON to flatten a json

func Map

func Map(j *jsonmap.Json, opt ...Option) ([]map[string]interface{}, error)

Map to tabify into a map array

func Slice

func Slice(j *jsonmap.Json, opt ...Option) ([][]interface{}, error)

Slice to tabify into a slice array. Note : first row contains headers

func Tabify added in v1.0.4

func Tabify(j *jsonmap.Json, writer TableWriter, opt ...Option) error

Tabify using a custom TableWriter

Types

type KeyExcluderFunc

type KeyExcluderFunc func([]string) bool

KeyExcluderFunc is a function to exclude a key from the input json

type KeyFormatterFunc

type KeyFormatterFunc func([]string) string

KeyFormatterFunc is a function to format a key from the input json

type Option

type Option func(o *Options)

Option is an option setter

func KeyExcluder

func KeyExcluder(v KeyExcluderFunc) Option

KeyExcluder sets the key excluder default : nil

func KeyFormatter

func KeyFormatter(v KeyFormatterFunc) Option

KeyFormatter sets the key formatter default : func (keys []string) => strings.Join(keys, "#")

type Options

type Options struct {
	KeyFormatter KeyFormatterFunc
	KeyExcluder  KeyExcluderFunc
}

Options are our tabify options

type TableWriter

type TableWriter interface {
	OpenRow()
	Cell(k string, v interface{}, deep int)
	CloseRow()
}

TableWriter is an interface to define a table writer

Jump to

Keyboard shortcuts

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