json

package module
v0.0.0-...-7fc401b Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: Unlicense Imports: 4 Imported by: 0

README

gopher-json GoDoc

forked from coinstack/gopher-json

Package json is a simple JSON encoder/decoder for coinstack/gopher-lua.

License

Public domain.

Documentation

Overview

Package json is a simple JSON encoder/decoder for gopher-lua.

Documentation

The following functions are exposed by the library:

decode(string): Decodes a JSON string. Returns nil and an error string if
                the string could not be decoded.
encode(value):  Encodes a value into a JSON string. Returns nil and an error
                string if the value could not be encoded.

Example

Below is an example usage of the library:

L := lua.NewState()
luajson.Preload(s)

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrFunction = errors.New("cannot encode function to JSON")
	ErrChannel  = errors.New("cannot encode channel to JSON")
	ErrState    = errors.New("cannot encode state to JSON")
	ErrUserData = errors.New("cannot encode userdata to JSON")
	ErrNested   = errors.New("cannot encode recursively nested tables to JSON")
)

Functions

func FromJSON

func FromJSON(L *lua.LState, value interface{}) lua.LValue

func Loader

func Loader(L *lua.LState) int

Loader is the module loader function.

func Preload

func Preload(L *lua.LState)

Preload adds json to the given Lua state's package.preload table. After it has been preloaded, it can be loaded using require:

local json = require("json")

func ToJSON

func ToJSON(value lua.LValue, visited map[*lua.LTable]bool) (data []byte, err error)

Types

type JsonValue

type JsonValue struct {
	lua.LValue
	// contains filtered or unexported fields
}

func NewJsonValue

func NewJsonValue(value lua.LValue) *JsonValue

func (JsonValue) MarshalJSON

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

Jump to

Keyboard shortcuts

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