jsonObject

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StringAnyMap

type StringAnyMap map[string]any

type Typ

type Typ struct {
	Valid bool

	StringAnyMap
	// contains filtered or unexported fields
}
var NullJsonObject Typ

func EmptyNotNullJsonObject

func EmptyNotNullJsonObject() Typ

EmptyNotNullJsonObject returns a new blank Typ NOTE: We cannot use a var for the EmptyNotNullJsonObject value because when we copy a lot of values around and

assign the var to multiple values throughout the program in multiple goroutines, we might get the panic message
"concurrent map read and map write" indicating that the value is being written and read simultaneously because
the same variable is being used at multiple places

func NewJsonObject

func NewJsonObject(key string, value any) Typ

func ToJsonObject

func ToJsonObject(v any) (Typ, error)

ToJsonObject will convert any object type to Typ using json.Marshal and json.Unmarshal

func (*Typ) AsByteSlice

func (j *Typ) AsByteSlice() []byte

func (*Typ) GetTopLevelElement

func (j *Typ) GetTopLevelElement(key string) any

GetTopLevelElement will return Top-Level element identified by key. If the key does not exist, nil is returned

func (*Typ) HasTopLevelArray

func (j *Typ) HasTopLevelArray() bool

func (*Typ) IsEmpty

func (j *Typ) IsEmpty() bool

func (*Typ) IsNotEmpty

func (j *Typ) IsNotEmpty() bool

func (Typ) MarshalJSON

func (j Typ) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface

func (*Typ) PrettyString

func (j *Typ) PrettyString() string

PrettyString will give the formatted string for this Typ

func (*Typ) Scan

func (j *Typ) Scan(value any) error

Scan implements the sql.Scanner interface. This method decodes a JSON-encoded value into the struct fields.

func (*Typ) SetNewTopLevelElement

func (j *Typ) SetNewTopLevelElement(key string, value any) (replacedExistingKey bool)

func (*Typ) String

func (j *Typ) String() string

func (*Typ) UnmarshalJSON

func (j *Typ) UnmarshalJSON(dataToUnmarshal []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*Typ) Value

func (j *Typ) Value() (driver.Value, error)

Value implements the driver.Valuer interface. This method returns the JSON-encoded representation of the struct.

Jump to

Keyboard shortcuts

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