DataError
UpdatedThe rule behind this error is on the JSON and TOML data page.
A source imports a .json or .toml file as a table. Three forms name one:
import data from "./data.json" import { coins, pets } from "./config.toml" local limits = import("./limits.toml") local raw = require("./raw.json")
The emit drops the extension: require("./data"). alloy build writes each data file a source names as a Luau module at the same place in the output, src/data.json becomes build/data.luau, and clean keeps it. A file that no source names stays as it is; alloy.toml and default.project.json never build.
The module returns the document as a table:
return { name = "game", ["max-players"] = 12, pets = { { name = "cat", legs = 4, }, }, }
Keys keep the document's order. A key that is not a Luau name, or is a keyword, goes in brackets. A JSON null is nil, a TOML datetime is a string, and a whole number has no .0.
The type check and the language server write the same module into their mirrors, so hover on data shows its table type, data. completes its keys, import { | } from "./config.toml" lists the top-level keys with their types, and go to definition on the path or on a name opens the file.
Three cases are diagnostics on the import: the file is missing, the document does not parse (the message names the line), and the file's stem collides with a module beside it. x.json beside x.aly or x.luau would build the same x.luau, so one of them gets a new name. A data path is relative, ./ or ../, and stays under [build] in.
