libjson

package
v1.16.8 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 11 Imported by: 1

Documentation

Index

Constants

View Source
const DefaultPackageName = "json"

DeafultPackageName is the package name used by LoadPackage.

Variables

This section is empty.

Functions

func Builtins

func Builtins(s *Serializer) []*libutil.Builtin

Builtins takes the default serializer for a lisp environment and returns a set of package builtin functions that use it.

func Dump

func Dump(v *lisp.LVal, stringNums bool) ([]byte, error)

Dump serializes the structure of v as a JSON formatted byte slice.

func Load

func Load(b []byte, stringNums bool) *lisp.LVal

Load parses b as JSON and returns an equivalent LVal.

func LoadPackage

func LoadPackage(env *lisp.LEnv) *lisp.LVal

LoadPackage adds the time package to env

Types

type Serializer

type Serializer struct {
	True             *lisp.LVal
	False            *lisp.LVal
	Null             *lisp.LVal
	UseStringNumbers bool
}

Serializer defines JSON serialization rules for lisp values.

func DefaultSerializer

func DefaultSerializer() *Serializer

func (*Serializer) Dump

func (s *Serializer) Dump(v *lisp.LVal, stringNums bool) ([]byte, error)

Dump serializes v as JSON and returns any error.

func (*Serializer) DumpBytesBuiltin

func (s *Serializer) DumpBytesBuiltin(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*Serializer) DumpMessageBuiltin

func (s *Serializer) DumpMessageBuiltin(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*Serializer) DumpStringBuiltin

func (s *Serializer) DumpStringBuiltin(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*Serializer) GoError deprecated

func (s *Serializer) GoError(v *lisp.LVal) error

GoError returns an error that represents v. If v is not LError then nil is returned.

Deprecated: GoError is no longer used internally for serialization and should be avoided.

func (*Serializer) GoFloat64 deprecated

func (s *Serializer) GoFloat64(v *lisp.LVal) (float64, bool)

GoFloat64 converts the numeric value that v represents to a float64 and returns it with the value true. If v does not represent a number GoFloat64 returns a false second argument

Deprecated: GoFloat64 is no longer used internally for serialization and should be avoided.

func (*Serializer) GoInt deprecated

func (s *Serializer) GoInt(v *lisp.LVal) (int, bool)

GoInt converts the numeric value that v represents to and int and returns it with the value true. If v does not represent a number GoInt returns a false second argument

Deprecated: GoInt is no longer used internally for serialization and should be avoided.

func (*Serializer) GoMap deprecated

func (s *Serializer) GoMap(v *lisp.LVal, stringNums bool) (SortedMap, bool)

GoMap converts an LSortMap to its Go equivalent and returns it with a true second argument. If v does not represent a map json serializable map GoMap returns a false second argument

Deprecated: GoMap is no longer used internally for serialization and should be avoided.

func (*Serializer) GoSlice deprecated

func (s *Serializer) GoSlice(v *lisp.LVal, stringNums bool) ([]interface{}, bool)

GoSlice returns the string that v represents and the value true. If v does not represent a string GoSlice returns a false second argument

Deprecated: GoSlice is no longer used internally for serialization and should be avoided.

func (*Serializer) GoString deprecated

func (s *Serializer) GoString(v *lisp.LVal) (string, bool)

GoString returns the string that v represents and the value true. If v does not represent a string GoString returns a false second argument

Deprecated: GoString is no longer used internally for serialization and should be avoided.

func (*Serializer) GoValue deprecated

func (s *Serializer) GoValue(v *lisp.LVal, stringNums bool) interface{}

GoValue converts v to its natural representation in Go. Quotes are ignored and all lists are turned into slices. Symbols are converted to strings. The value Nil() is converted to nil. Functions are returned as is.

Deprecated: GoValue is no longer used internally for serialization and should be avoided.

func (*Serializer) Load

func (s *Serializer) Load(b []byte, stringNums bool) *lisp.LVal

Load parses b and returns an LVal representing its structure.

func (*Serializer) LoadBytesBuiltin

func (s *Serializer) LoadBytesBuiltin(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*Serializer) LoadMessageBuiltin

func (s *Serializer) LoadMessageBuiltin(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*Serializer) LoadStringBuiltin

func (s *Serializer) LoadStringBuiltin(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*Serializer) MessageBytesBuiltin

func (s *Serializer) MessageBytesBuiltin(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

func (*Serializer) SymbolName deprecated

func (s *Serializer) SymbolName(v *lisp.LVal) (string, bool)

SymbolName returns the name of the symbol that v represents and the value true. If v does not represent a symbol SymbolName returns a false second argument

Deprecated: SymbolName is no longer used internally for serialization and should be avoided.

func (*Serializer) UseStringNumbersBuiltin

func (s *Serializer) UseStringNumbersBuiltin(env *lisp.LEnv, args *lisp.LVal) *lisp.LVal

type SortedMap

type SortedMap map[string]interface{}

SortedMap implements lisp.Map and only supports string keys. Values must be lisp.LVal.

func (SortedMap) Del added in v1.14.0

func (m SortedMap) Del(k *lisp.LVal) *lisp.LVal

func (SortedMap) Entries added in v1.14.0

func (m SortedMap) Entries(cells []*lisp.LVal) *lisp.LVal

func (SortedMap) Get added in v1.14.0

func (m SortedMap) Get(k *lisp.LVal) (*lisp.LVal, bool)

func (SortedMap) Keys added in v1.14.0

func (m SortedMap) Keys() (keys *lisp.LVal)

func (SortedMap) Len added in v1.14.0

func (m SortedMap) Len() int

func (SortedMap) Set added in v1.14.0

func (m SortedMap) Set(k *lisp.LVal, v *lisp.LVal) *lisp.LVal

Jump to

Keyboard shortcuts

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