gjson

package
v0.0.0-...-04ff805 Latest Latest
Warning

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

Go to latest
Published: May 22, 2022 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatIndent

func FormatIndent(p []byte) ([]byte, error)

func IsValid

func IsValid(json string) bool

func Iterate

func Iterate(jsonStr *string, indent bool, iterFn IterFn) error

func JSONDecode

func JSONDecode(data []byte, to interface{}) error

JSONDecode decodes JSON data into a structure

func JSONEncode

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

JSONEncode encodes structure data into JSON

func MarshalAndPrintln

func MarshalAndPrintln(x interface{})

func MarshalBuffer

func MarshalBuffer(v interface{}, indent bool) ([]byte, error)

func MarshalBufferDefault

func MarshalBufferDefault(v interface{}, indent bool) []byte

func MarshalBufferWithErrFmt

func MarshalBufferWithErrFmt(v interface{}, indent bool, errFmt string) []byte

func MarshalString

func MarshalString(v interface{}, indent bool) (string, error)

func MarshalStringDefault

func MarshalStringDefault(v interface{}, indent bool) string

func MarshalStringWithErrFmt

func MarshalStringWithErrFmt(v interface{}, indent bool, errFmt string) string

func Set

func Set(jsonstr string, path []string, val interface{}) (string, error)

Types

type Cell

type Cell struct {
	Data string
	// contains filtered or unexported fields
}

type Column

type Column struct {
	Cells []Cell
}

type IterFn

type IterFn = func(key string, val interface{}) (newVal interface{}, modified bool, err error)

type JifTimestamp

type JifTimestamp time.Time

Json index friendly timestamp. Why choose format time as nanosecond int64, but not human readable string? time.RFC3339Nano is the only format which can format time with nanosecond accuracy, but it has timezone information in it, when you need create unique index for timestamp in json/jsonb database, same epoch timestamps in different timezone may be considered as different string/index.

func (JifTimestamp) MarshalJSON

func (t JifTimestamp) MarshalJSON() ([]byte, error)

type JsonValue

type JsonValue gjson.Result

func Get

func Get(json, path string) JsonValue

func (JsonValue) Bool

func (v JsonValue) Bool() bool

func (JsonValue) Exists

func (v JsonValue) Exists() bool

func (JsonValue) Float

func (v JsonValue) Float() float64

func (JsonValue) Int64

func (v JsonValue) Int64() int64

func (JsonValue) String

func (v JsonValue) String() string

func (JsonValue) Time

func (v JsonValue) Time() time.Time

type Row

type Row []string

type Table

type Table struct {
	Rows []Row
}

func NewTableFromExcel

func NewTableFromExcel(filename string) (*Table, error)

func NewTableFromString

func NewTableFromString(json string) (*Table, error)

func (*Table) AddColumn

func (d *Table) AddColumn(afterColumnIndex int, newColumn Column) error

func (*Table) AddRow

func (d *Table) AddRow(afterRowIndex int, newRow Row) error

func (*Table) GetColumn

func (d *Table) GetColumn(columnIndex int) (Column, error)

func (*Table) GetColumnsCount

func (d *Table) GetColumnsCount() (int, error)

func (*Table) GetRow

func (d *Table) GetRow(rowIndex int) (Row, error)

func (*Table) GetRowsCount

func (d *Table) GetRowsCount() (int, error)

func (*Table) RemoveColumn

func (d *Table) RemoveColumn(columnIndex int) error

Jump to

Keyboard shortcuts

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