js

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MIT Imports: 9 Imported by: 0

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 return any value of the key * @param _default any * @param atribs ...string * @return *generic.Any *

func (*Item) Array

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

* * Array return []Json value of the key * @param atribs ...string * @return []Json *

func (*Item) Bool

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

* * Bool return boolean value of the key * @param atribs ...string * @return bool *

func (*Item) Data

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

* * Data return JsonD value of the key * @param atribs ...string * @return JsonD *

func (*Item) Del

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

* * Del a value from a item * @param key string * @return bool *

func (*Item) FromString

func (it *Item) FromString(src string) error

* * FromString * @param src string * @return error *

func (*Item) Get

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

* * Get a value from a key * @param key string * @return interface{} *

func (*Item) IdT

func (it *Item) IdT() string

* * Str return string value of the key * @param _default string * @param atribs ...string * @return *generic.Str *

func (*Item) Index

func (it *Item) Index() int

* * Index return the value of the key * @param atribs ...string * @return int *

func (*Item) Int

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

* * Int return the value of the key * @param atribs ...string * @return int *

func (*Item) Int64

func (it *Item) Int64(atribs ...string) int64

* * Int64 return the value of the key * @param atribs ...string * @return int *

func (*Item) IsDiferent

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

* * IsDiferent return if the item is diferent * @param new Json * @return bool *

func (*Item) Json

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

* * Json return Json value of the key * @param atribs ...string * @return Json *

func (*Item) Key

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

* * Key return the value of the key * @param atribs ...string * @return string *

func (*Item) Lowcase

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

* * Lowcase return the value of the key in lowercase * @param _default string * @param atribs ...string * @return string *

func (*Item) Num

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

* * Num return float64 value of the key * @param atribs ...string * @return float64 *

func (*Item) ScanRows

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

* * ScanRows load rows to a item * @param rows *sql.Rows * @return error *

func (*Item) Set

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

* * Set a value from a item * @param key string * @param val any * @return bool *

func (*Item) Str

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

* * Str return the value of the key * @param atribs ...string * @return string *

func (*Item) Time

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

* * Time return time.Time value of the key * @param atribs ...string * @return time.Time *

func (*Item) Titlecase

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

* * Titlecase return the value of the key in titlecase * @param _default string * @param atribs ...string * @return string *

func (*Item) ToByte

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

* * ToByte covert to byte values * @return []byte *

func (*Item) ToJson

func (it *Item) ToJson() Json

* * ToJson covert to Json values * @return Json *

func (*Item) ToString

func (it *Item) ToString() string

* * ToString convert to string values * @return string *

func (*Item) Uppcase

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

* * Uppcase return the value of the key in uppercase * @param _default string * @param atribs ...string * @return string *

func (*Item) ValAny

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

* * ValAny return any value of the key * @param _default any * @param atribs ...string * @return any *

func (*Item) ValBool

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

* * ValBool return bool value of the key * @param _default bool * @param atribs ...string * @return bool *

func (*Item) ValInt

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

* * ValInt return int value of the key * @param _default int * @param atribs ...string * @return int *

func (*Item) ValJson

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

* * ValJson return Json value of the key * @param _default Json * @param atribs ...string * @return Json *

func (*Item) ValNum

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

* * ValNum return float64 value of the key * @param _default float64 * @param atribs ...string * @return float64 *

func (*Item) ValStr

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

* * ValStr return string value of the key * @param _default string * @param atribs ...string * @return string *

func (*Item) ValTime

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

* * ValTime return time.Time value of the key * @param _default time.Time * @param atribs ...string * @return time.Time *

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 * @param idx int * @atrib ...string * @return bool *

func (*Items) Del

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

* * Del a value from the key * @param idx int * @param key string * @return bool *

func (*Items) FromString

func (it *Items) FromString(src string) error

* * FromString * @param src string * @return error *

func (*Items) Get

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

* * Get a value from the key * @param idx int * @param key string * @return interface{} *

func (*Items) IdT

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

* * IdT return the value of the key * @param idx int * @return string *

func (*Items) Int

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

* * Int return the value of the key * @param idx int * @atrib ...string * @return int *

func (*Items) Json

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

* * Json return the value of the key * @param idx int * @atrib ...string * @return Json *

func (*Items) Key

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

* * Index return the value of the key * @param idx int * @atrib ...string * @return int *

func (*Items) Lowcase

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

* * Lowcase return the value of the key in lowercase * @param idx int * @param _default string * @param atribs ...string * @return string *

func (*Items) Num

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

* * Num return the value of the key * @param idx int * @atrib ...string * @return float64 *

func (*Items) Scan

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

* * Items methods * @param src interface{} * @return error *

func (*Items) Set

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

* * Set a value from the key * @param idx int * @param key string * @param val interface{} * @return bool *

func (*Items) Str

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

* * Str return the value of the key * @param idx int * @atrib ...string * @return string *

func (*Items) Titlecase

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

* * Titlecase return the value of the key in titlecase * @param idx int * @param _default string * @param atribs ...string * @return string *

func (*Items) ToByte

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

* * ToByte * @return []byte *

func (*Items) ToJson

func (it *Items) ToJson() Json

* * ToJson return the value type Json * @return Json *

func (*Items) ToList

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

* * ToList return the value type List * @param all int * @param page int * @param rows int * @return List *

func (*Items) ToString

func (it *Items) ToString() string

* * ToString * @return string *

func (*Items) Uppcase

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

* * Uppcase return the value of the key in uppercase * @param idx int * @param _default string * @param atribs ...string * @return string *

func (*Items) ValAny

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

* * ValAny return the value of the key * @param idx int * @param _default any * @param atribs ...string * @return any *

func (*Items) ValStr

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

* * ValStr return the value of the key * @param idx int * @param _default string * @param atribs ...string * @return string *

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)

* * Append s json with a other json * @param obj Json * @return *Json * @return bool *

func ByteToJson

func ByteToJson(scr interface{}) Json

ByteToJson convert a byte to a Json

func Chage

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

* * Chage s json with a other json * @param obj Json * @return *Json * @return bool *

func Marshal

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

* * Marshall convert a interface to a json * @param src interface{} * @return Json *

func Merge

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

* * Merge s json with a other json * @param obj Json * @return *Json * @return 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 (Json) Any

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

* * Any return any value of the key * @param _default any * @param atribs ...string * @return *generic.Any *

func (Json) Append

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

* * Append s json with a other json * @param obj Json * @return *Json * @return bool *

func (Json) Array

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

* * Array return the value of the key * @param atrib string * @return []Json *

func (Json) Bool

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

* * Bool return the value of the key * @param atribs ...string * @return bool *

func (Json) Chage

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

* * Chage s json with a other json * @param obj Json * @return *Json * @return bool *

func (Json) Clone

func (s Json) Clone() Json

* * Clone a json * @return Json *

func (Json) Data

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

* * Json return the value of the key * @param atrib string * @return Json *

func (*Json) Del

func (s *Json) Del(key string) bool

* * Del a value in the key * @param key string * @return bool *

func (Json) ExistKey

func (s Json) ExistKey(key string) bool

* * ExistKey return if the key exist * @param key string * @return bool *

func (Json) Get

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

* * IsDiferent return if the json is diferent * @param old Json * @param new Json * @return bool *

func (Json) Id

func (s Json) Id() string

* * Id return the value of the key * @return string *

func (Json) IdT

func (s Json) IdT() string

* * IdT return the value of the key * @return string *

func (Json) Index

func (s Json) Index() int

* * Index return the value of the key * @return int *

func (Json) Int

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

* * Int return the value of the key * @param atribs ...string * @return int *

func (Json) Int64

func (s Json) Int64(atribs ...string) int64

* * Int64 return the value of the key * @param atribs ...string * @return int64 *

func (Json) IsDiferent

func (s Json) IsDiferent(new Json) bool

* * IsDiferent return if the json is diferent * @param new Json * @return bool *

func (Json) IsEmpty

func (s Json) IsEmpty() bool

* * Empty return if the json is empty * @return bool *

func (Json) Json

func (s Json) Json(atrib string) Json

* * Json return the value of the key * @param atrib string * @return Json *

func (Json) Key

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

* * Key return the value of the key * @param atribs ...string * @return string *

func (Json) Merge

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

* * Merge s json with a other json * @param obj Json * @return *Json * @return bool *

func (Json) Num

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

* * Num return the value of the key * @param atribs ...string * @return float64 *

func (*Json) Scan

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

* * Scan load rows to a json * @param src interface{} * @return error *

func (*Json) ScanRows

func (s *Json) ScanRows(rows *sql.Rows) error

* * ScanRows load rows to a json * @param rows *sql.Rows * @return error *

func (*Json) Set

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

* * Set a value in the key * @param key string * @param val interface{} * @return bool *

func (Json) Str

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

* * Str return the value of the key * @param atribs ...string * @return string *

func (Json) Time

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

* * Time return the value of the key * @param atribs ...string * @return time.Time *

func (Json) ToByte

func (s Json) ToByte() []byte

* * ToByte convert a json to a []byte * @return []byte *

func (Json) ToItem

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

* * ToItem convert a json to a item * @param src interface{} * @return Item *

func (Json) ToQuote

func (s Json) ToQuote() string

* * ToQuote convert a json to a quote string * @return string *

func (Json) ToString

func (s Json) ToString() string

* * ToString convert a json to a string * @return string *

func (Json) ToUnquote

func (s Json) ToUnquote() string

* * ToUnquote convert a json to a unquote string * @return string *

func (*Json) Update

func (s *Json) Update(fromJson Json) error

* * Update a json with a other json * @param fromJson Json * @return error *

func (Json) ValAny

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

* * ValAny return any value of the key * @param _default any * @param atribs ...string * @return any *

func (Json) ValBool

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

* * ValBool return bool value of the key * @param _default bool * @param atribs ...string * @return bool *

func (Json) ValInt

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

* * ValInt return int value of the key * @param _default int * @param atribs ...string * @return int *

func (Json) ValInt64

func (s Json) ValInt64(_default int64, atribs ...string) int64

func (Json) ValJson

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

* * ValJson return Json value of the key * @param _default Json * @param atribs ...string * @return Json *

func (Json) ValNum

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

* * ValNum return float64 value of the key * @param _default float64 * @param atribs ...string * @return float64 *

func (Json) ValStr

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

* * ValStr return string value of the key * @param _default string * @param atribs ...string * @return string *

func (Json) ValTime

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

* * ValTime return time value of the key * @param _default time.Time * @param atribs ...string * @return time.Time *

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