2019-11-18 20:33:15 +03:00
|
|
|
// 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.
|
|
|
|
//
|
2020-09-23 02:43:58 +03:00
|
|
|
// The following types are supported:
|
|
|
|
//
|
|
|
|
// Lua | JSON
|
|
|
|
// ---------+-----
|
|
|
|
// nil | null
|
|
|
|
// number | number
|
|
|
|
// string | string
|
|
|
|
// table | object: when table is non-empty and has only string keys
|
|
|
|
// | array: when table is empty, or has only sequential numeric keys
|
|
|
|
// | starting from 1
|
|
|
|
//
|
|
|
|
// Attempting to encode any other Lua type will result in an error.
|
|
|
|
//
|
2019-11-18 20:33:15 +03:00
|
|
|
// Example
|
|
|
|
//
|
|
|
|
// Below is an example usage of the library:
|
2020-09-23 02:43:58 +03:00
|
|
|
// import (
|
|
|
|
// luajson "layeh.com/gopher-json"
|
|
|
|
// )
|
|
|
|
//
|
2019-11-18 20:33:15 +03:00
|
|
|
// L := lua.NewState()
|
2021-02-04 00:30:55 +03:00
|
|
|
// luajson.Preload(L)
|
2019-11-18 20:33:15 +03:00
|
|
|
package json // import "layeh.com/gopher-json"
|