json.decode()

Overview

Decodes the JSON-encoded data structure and returns a Lua object (table) with the data. The return value is a Lua object when the data is successfully decoded or, in the case of an error, three values: nil, the position of the next character that doesn't belong to the object, and an error message.

Syntax

json.decode( data [, position [, nullval]] )

data (required)

position (optional)

Number. Index within data to start decoding (default is 1 if omitted).

nullval (optional)

Value to be returned for items with a value of json.null (see json.encode()). This is useful if your data contains items which are "null" but you need to know of their existence (in Lua, table items with values of nil don't normally exist).