Lua doesn't have a separate array type. Both arrays and dictionaries are tables. This means luadata needs a strategy for deciding when a table should become a JSON array vs a JSON object.
There are two ways to write array-like tables in Lua. The first uses implicit indices:
fruits = {"apple", "banana", "cherry"}
The second uses explicit integer keys:
fruits = {
[1] = "apple",
[2] = "banana",
[3] = "cherry",
}
Both represent the same data in Lua, but the intent may differ. By default, luadata uses ArrayModeSparse with a MaxGap of 20, which renders both forms as JSON arrays:
{
"fruits": [
"apple",
"banana",
"cherry"
]
}
The array mode option gives you control over this behavior. The chosen mode applies to all tables in the output. If you need per-field control, a JSON Schema can declare each field's type explicitly — see Schema vs Heuristics.
The next three examples cover each array mode in detail.
Want more flexibility? Open the interactive converter to try any Lua input with all available options.