Railgun

if it ain't broke, we'll break it

User Tools

Site Tools


senses:packages:kmj-json

This is an old revision of the document!


Table of Contents

kmj-json

The kmj-json package provides a JSON codec.

The runtime provides this library through the luaL_newlib auxiliary library function, so all fields can be assumed to be functions.

decode

The decode field contains a function for decoding a JSON encoded type.

Syntax

decode(input: string): (output: any)

This function takes a single argument, that being the JSON encoded representation of a type, and will return a single value, that being the decoded Lua equivalent value type of the given JSON. If the input cannot be parsed, a Lua nil will be returned.

encode

The encode field contains a function for encoding a Lua value into a JSON encoded type.

Syntax

encode(input: any): (output: string|nil)

This function takes a single argument, that being the Lua value that is intended to be converted to a JSON encoded string, and a single return value containing the JSON encoded representation of the given input. If the input cannot be understood, nil will be returned. Of the eight basic Lua types, nil, boolean, number, string and table are supported.

senses/packages/kmj-json.1753665649.txt.gz · Last modified: by flash