luadata 0.1.14

Parse Lua data files and convert to JSON
Documentation

luadata

A Lua data parser that converts Lua data files (such as World of Warcraft SavedVariables) to JSON.

Install

cargo add luadata

Usage

use luadata::{text_to_json, file_to_json, ParseConfig};

// From a string
let json = text_to_json("input", r#"playerName = "Thrall""#, ParseConfig::new())?;

// From a file
let json = file_to_json("config.lua", ParseConfig::new())?;

// With options
let mut config = ParseConfig::new();
config.array_mode = Some(luadata::options::ArrayMode::IndexOnly);
config.empty_table_mode = luadata::options::EmptyTableMode::Array;
let json = text_to_json("input", lua_string, config)?;

Options

All parse functions accept a ParseConfig with three option groups:

  • String transform — limit string length during parsing (truncate, empty, redact, replace)
  • Array detection — control how integer-keyed Lua tables map to JSON arrays (sparse, index-only, none)
  • Empty tables — choose how empty Lua tables render in JSON (null, omit, array, object)

See the full options documentation for details and examples.

Links