Luadata by Example

Array Mode: None

The "none" array mode is the most conservative. It disables all array rendering — every table becomes a JSON object, even implicit index tables.

lua
fruits = {"apple", "banana", "cherry"}
scores = {
    [1] = 100,
    [2] = 85,
    [3] = 92,
}

With array mode "none", both tables render as objects with string keys:

go
reader, err := luadata.TextToJSON("input", input,
    luadata.WithArrayMode("none"),
)
output
{
  "fruits": {
    "1": "apple",
    "2": "banana",
    "3": "cherry"
  },
  "scores": {
    "1": 100,
    "2": 85,
    "3": 92
  }
}

This mode is useful when dealing with data that may change shape over time. With other array modes, a table might render as a JSON array in one version of the data and an object in another, forcing consumers to handle mixed types. With this mode, the output is always objects with numeric string keys, keeping the JSON structure consistent and predictable.

From the CLI:

bash
luadata tojson --array-mode=none input.lua

Want more flexibility? Open the interactive converter to try any Lua input with all available options.