et

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2024 License: MIT Imports: 11 Imported by: 9

Documentation

Index

Constants

View Source
const TpArray = 2
View Source
const TpObject = 1

TpObject and TpArray type

Variables

This section is empty.

Functions

func ArrayToString

func ArrayToString(vals []Json) string

ArrayToJson convert a []interface{} to a Json

func IsDiferent

func IsDiferent(a, b Json) bool

IsDiferent compare two Json and return true if they are different

func NotInSlice

func NotInSlice(la, lb []Json, key string) []string

InSlice return the items that are in the slice

func Quote

func Quote(val interface{}) any

Quote add quotes to a value

func SliceFindIndex

func SliceFindIndex(item Json, list []Json, key string) int

SliceFindIndex find the index of an item in a slice

func ToString

func ToString(val interface{}) string

ToString convert a value to a string

func Unquote

func Unquote(val interface{}) any

Unquote remove the quotes from a value

func Val

func Val(data Json, _default any, atribs ...string) any

Val get a value from a Json

Types

type Item

type Item struct {
	Ok     bool `json:"ok"`
	Result Json `json:"result"`
}

Item struct to define a item

func (*Item) Any

func (it *Item) Any(_default any, atribs ...string) *generic.Any

Any get a value from a item

func (*Item) Array

func (it *Item) Array(atrib string) []Json

Array get a []Json value from a item

func (*Item) ArrayStr

func (it *Item) ArrayStr(atrib string) []string

ArrayStr get a []string value from a item

func (*Item) Bool

func (it *Item) Bool(atribs ...string) bool

Bool get a bool value from a item

func (*Item) Data

func (it *Item) Data(atribs ...string) JsonD

Data get a JsonD value from a item

func (*Item) Del

func (it *Item) Del(key string) bool

Del a value from a item

func (*Item) Get

func (it *Item) Get(key string) interface{}

Get a value from a item

func (*Item) Id

func (it *Item) Id() string

Id get a string value from a item

func (*Item) IdT

func (it *Item) IdT() string

IdT get a string value from a item

func (*Item) Index

func (it *Item) Index() int

Index get a int value from a item

func (*Item) Int

func (it *Item) Int(atribs ...string) int

Int get a int value from a item

func (*Item) IsDiferent

func (it *Item) IsDiferent(new Json) bool

IsDiferent compare two items

func (*Item) Json

func (it *Item) Json(atribs ...string) Json

Json get a Json value from a item

func (*Item) Key

func (it *Item) Key(atribs ...string) string

Key get a string value from a item

func (*Item) Lowcase

func (it *Item) Lowcase(_default string, atribs ...string) string

Lowcase a string value from a item

func (*Item) Num

func (it *Item) Num(atribs ...string) float64

Num get a float64 value from a item

func (*Item) Scan

func (it *Item) Scan(rows *sql.Rows) error

Scan a row from a sql query

func (*Item) Set

func (it *Item) Set(key string, val any) bool

Set a value from a item

func (*Item) Str

func (it *Item) Str(atribs ...string) string

Str get a string value from a item

func (*Item) Time

func (it *Item) Time(atribs ...string) time.Time

Time get a time.Time value from a item

func (*Item) Titlecase

func (it *Item) Titlecase(_default string, atribs ...string) string

Titlecase a string value from a item

func (*Item) ToByte

func (it *Item) ToByte() []byte

ToByte get a []byte value from a item

func (*Item) ToJson

func (it *Item) ToJson() Json

ToJson get a Json value from a item

func (*Item) ToScan

func (it *Item) ToScan(src interface{}) error

ToScan a struct from a item

func (*Item) ToString

func (it *Item) ToString() string

ToString get a string value from a item

func (*Item) Uppcase

func (it *Item) Uppcase(_default string, atribs ...string) string

Uppcase a string value from a item

func (*Item) ValAny

func (it *Item) ValAny(_default any, atribs ...string) any

ValAny get a value from a item

func (*Item) ValBool

func (it *Item) ValBool(_default bool, atribs ...string) bool

ValBool get a bool value from a item

func (*Item) ValInt

func (it *Item) ValInt(_default int, atribs ...string) int

ValInt get a int value from a item

func (*Item) ValJson

func (it *Item) ValJson(_default Json, atribs ...string) Json

ValJson get a Json value from a item

func (*Item) ValNum

func (it *Item) ValNum(_default float64, atribs ...string) float64

ValNum get a float64 value from a item

func (*Item) ValStr

func (it *Item) ValStr(_default string, atribs ...string) string

ValStr get a string value from a item

func (*Item) ValTime

func (it *Item) ValTime(_default time.Time, atribs ...string) time.Time

ValTime get a time.Time value from a item

type Items

type Items struct {
	Ok     bool   `json:"ok"`
	Count  int    `json:"count"`
	Result []Json `json:"result"`
}

Items struct to define a items

func (*Items) Bool

func (it *Items) Bool(idx int, atribs ...string) bool

Bool return the value of the key

func (*Items) Del

func (it *Items) Del(idx int, key string) bool

Del a value from the key

func (*Items) Get

func (it *Items) Get(idx int, key string) interface{}

Get return the value of the key

func (*Items) Id

func (it *Items) Id(idx int) string

Id return the value of the key

func (*Items) IdT

func (it *Items) IdT(idx int) string

IdT return the value of the key

func (*Items) Int

func (it *Items) Int(idx int, atribs ...string) int

Int return the value of the key

func (*Items) Json

func (it *Items) Json(idx int, atribs ...string) Json

Json return the value of the key

func (*Items) Key

func (it *Items) Key(idx int, atribs ...string) string

Key return the value of the key

func (*Items) Lowcase

func (it *Items) Lowcase(idx int, _default string, atribs ...string) string

Lowcase return the value of the key in lowercase

func (*Items) Num

func (it *Items) Num(idx int, atribs ...string) float64

Num return the value of the key

func (*Items) Scan

func (it *Items) Scan(src interface{}) error

Scan a row from a sql query

func (*Items) Set

func (it *Items) Set(idx int, key string, val interface{}) bool

Set a value to the key

func (*Items) Str

func (it *Items) Str(idx int, atribs ...string) string

Str return the value of the key

func (*Items) Titlecase

func (it *Items) Titlecase(idx int, _default string, atribs ...string) string

Titlecase return the value of the key in titlecase

func (*Items) ToJson

func (it *Items) ToJson() Json

ToJson return the value of the key

func (*Items) ToList

func (it *Items) ToList(all, page, rows int) List

ToList return the value of the key

func (*Items) ToString

func (it *Items) ToString() string

ToString return the value of the key

func (*Items) Uppcase

func (it *Items) Uppcase(idx int, _default string, atribs ...string) string

Uppcase return the value of the key in uppercase

func (*Items) ValAny

func (it *Items) ValAny(idx int, _default any, atribs ...string) any

ValAny return the value of the key

func (*Items) ValStr

func (it *Items) ValStr(idx int, _default string, atribs ...string) string

ValStr return the value of the key

type Json

type Json map[string]interface{}

Json type

func ApendJson

func ApendJson(m Json, n Json) Json

ApendJson add a Json to a Json

func Append

func Append(a, b Json) (Json, bool)

func ByteToJson

func ByteToJson(scr interface{}) Json

ByteToJson convert a byte to a Json

func Chage

func Chage(a, b Json) (Json, bool)

func JsonToArrayJson

func JsonToArrayJson(src map[string]interface{}) ([]Json, error)

JsonToArrayJson convert a map to a json array

func Marshal

func Marshal(src interface{}) (Json, error)

Marshal convert a interface to a json

func Merge

func Merge(a, b Json) (Json, bool)

func OkOrNotJson

func OkOrNotJson(condition bool, ok Json, not Json) Json

OkOrNotJson return a Json depending on a condition

func ToJson

func ToJson(src interface{}) (Json, error)

ToJson convert a value to a Json

func ToJsonArray

func ToJsonArray(vals []interface{}) ([]Json, error)

ToJsonArray convert a value to a []Json

func ToUnit8Json

func ToUnit8Json(src interface{}) Json

ToUnit8Json convert a value to a Json

func (Json) Any

func (s Json) Any(_default any, atribs ...string) *generic.Any

Any return the value of the key

func (Json) Append

func (s Json) Append(obj Json) (*Json, bool)

Append s json with a other json

func (Json) Array

func (s Json) Array(atrib string) []Json

Array return the value of the key

func (Json) ArrayAny

func (s Json) ArrayAny(atrib string) []any

ArrayAny return the value of the key

func (Json) ArrayStr

func (s Json) ArrayStr(atrib string) []string

ArrayStr return the value of the key

func (Json) Bool

func (s Json) Bool(atribs ...string) bool

Bool return the value of the key

func (Json) Chage

func (s Json) Chage(obj Json) (*Json, bool)

Cange s json with a other json and return the change and is changed a json

func (Json) Clone

func (s Json) Clone() Json

Clone a json

func (Json) Data

func (s Json) Data(atrib ...string) JsonD

Data return the value of the key

func (Json) Del

func (s Json) Del(key string) bool

Del a value from the key

func (Json) Emptyt

func (s Json) Emptyt() bool

Empty return if the json is empty

func (Json) ExistKey

func (s Json) ExistKey(key string) bool

ExistKey return if the key exist in the json

func (Json) Get

func (s Json) Get(key string) interface{}

Get return the value of the key

func (Json) Id

func (s Json) Id() string

Id return the value of the key

func (Json) IdT

func (s Json) IdT() string

IdT return the value of the key

func (Json) Index

func (s Json) Index() int

Index return the value of the key

func (Json) Int

func (s Json) Int(atribs ...string) int

Int return the value of the key

func (Json) IsDiferent

func (s Json) IsDiferent(new Json) bool

IsDiferent compare two json

func (Json) Json

func (s Json) Json(atrib string) Json

Json return the value of the key

func (Json) Key

func (s Json) Key(atribs ...string) string

Key return the value of the key

func (Json) Merge

func (s Json) Merge(obj Json) (*Json, bool)

Merge s json with a other json

func (Json) Num

func (s Json) Num(atribs ...string) float64

Num return the value of the key

func (*Json) Scan

func (s *Json) Scan(src interface{}) error

Scan convert a driver value to a json

func (Json) Set

func (s Json) Set(key string, val interface{}) bool

Set a value from a json

func (Json) Str

func (s Json) Str(atribs ...string) string

Str return the value of the key

func (Json) Time

func (s Json) Time(atribs ...string) time.Time

Time return the value of the key

func (Json) ToByte

func (s Json) ToByte() []byte

ToByte convert a json to a byte

func (Json) ToItem

func (s Json) ToItem(src interface{}) Item

ToItem convert a json to a item

func (Json) ToQuote

func (s Json) ToQuote() string

ToQuote convert a json to a quote string

func (*Json) ToScan

func (s *Json) ToScan(src interface{}) error

ToScan convert a json to a struct

func (Json) ToString

func (s Json) ToString() string

ToString convert a json to a string

func (Json) ToUnquote

func (s Json) ToUnquote() string

ToUnquote convert a json to a unquote string

func (Json) Update

func (s Json) Update(fromJson Json) error

Update a json with a new json

func (Json) ValAny

func (s Json) ValAny(_default any, atribs ...string) any

ValAny return the value of the key

func (Json) ValBool

func (s Json) ValBool(_default bool, atribs ...string) bool

ValBool return the value of the key

func (Json) ValInt

func (s Json) ValInt(_default int, atribs ...string) int

ValInt return the value of the key

func (Json) ValJson

func (s Json) ValJson(_default Json, atribs ...string) Json

ValJson return the value of the key

func (Json) ValNum

func (s Json) ValNum(_default float64, atribs ...string) float64

ValNum return the value of the key

func (Json) ValStr

func (s Json) ValStr(_default string, atribs ...string) string

ValStr return the value of the key

func (Json) ValTime

func (s Json) ValTime(_default time.Time, atribs ...string) time.Time

ValTime return the value of the key

func (Json) Value

func (s Json) Value() (driver.Value, error)

Value convert a json to a driver value

type JsonD

type JsonD struct {
	Type  int
	Value interface{}
}

JsonD struct to define a json data

type List

type List struct {
	Rows   int    `json:"rows"`
	All    int    `json:"all"`
	Count  int    `json:"count"`
	Page   int    `json:"page"`
	Start  int    `json:"start"`
	End    int    `json:"end"`
	Result []Json `json:"result"`
}

List struct to use in et

func (*List) ToJson

func (it *List) ToJson() Json

ToJson return the value of the key

Jump to

Keyboard shortcuts

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