Lua data files often contain multiple top-level variable assignments. Each one becomes a key in the resulting JSON object.
playerName = "Jaina"
playerLevel = 60
isOnline = true
package main
import (
"fmt"
"io"
"github.com/mmobeus/luadata"
)
func main() {
input := `playerName = "Jaina"
playerLevel = 60
isOnline = true`
reader, err := luadata.TextToJSON("input", input)
if err != nil {
panic(err)
}
result, _ := io.ReadAll(reader)
fmt.Println(string(result))
}
{
"playerName": "Jaina",
"playerLevel": 60,
"isOnline": true
}
The order of keys in the JSON output matches the order of assignments in the Lua file. luadata preserves insertion order rather than alphabetizing keys.
Want more flexibility? Open the interactive converter to try any Lua input with all available options.