Module jls.util.json

Provide JavaScript Object Notation (JSON) codec.

Functions

encode (value) Returns the JSON encoded string representing the specified value.
decode (jsonString) Returns the value representing the specified string.
parse (jsonString) Returns the value representing the specified string.
stringify (value, space) Returns the JSON encoded string representing the specified value.

Fields

null The opaque value representing null.


Functions

encode (value)
Returns the JSON encoded string representing the specified value.

Parameters:

  • value table The value to encode.

Returns:

    the encoded string.

Usage:

    require('jls.util.json').encode({aString = 'Hello world !'}) -- Returns '{"aString":"Hello world !"}'
decode (jsonString)
Returns the value representing the specified string.

Parameters:

  • jsonString string The JSON string to decode.

Returns:

    the decoded value.

Usage:

    require('jls.util.json').decode('{"aString":"Hello world !"}') -- Returns {aString = 'Hello world !'}
parse (jsonString)
Returns the value representing the specified string.

Parameters:

  • jsonString string The JSON string to parse.

Returns:

    the parsed value.
stringify (value, space)
Returns the JSON encoded string representing the specified value. When specifying space, the encoded string will includes new lines.

Parameters:

  • value table The value to to convert to a JSON encoded string.
  • space number The number of space characters to use as white space.

Returns:

    the encoded string.

Fields

null
The opaque value representing null.
  • null
generated by LDoc 1.4.6 Last updated 2022-01-22 16:32:56