| Crates.io | lua2json |
| lib.rs | lua2json |
| version | 0.1.0 |
| created_at | 2023-02-20 17:58:17.785477+00 |
| updated_at | 2023-02-20 17:58:17.785477+00 |
| description | A Lua parser that outputs JSON |
| homepage | |
| repository | https://github.com/FauxFaux/lua2json |
| max_upload_size | |
| id | 790044 |
| size | 12,236 |
lua2json is a simple tool to convert Lua tables to JSON.
It reads lines from stdin and writes to stdout.
It consumes tables in serpent format, which is also the input
format for literal tables in the Lua language.
e.g., given a line containing:
{foo = "bar", baz = { qux = "quux" }}
..it will print:
{"foo":"bar","baz":{"qux":"quux"}}
This is quite similar to:
json=require "json"
for s in io.open("/dev/stdin", "r"):read("a"):gmatch("[^\n]+") do
load("g="..s)()
print(json.encode(g))
end
...except it doesn't execute arbitrary code (and it happens to be 6x faster and order-preserving, but if you care about that, you probably need help.)
The behaviour on mixed dict/arrays is MADE UP. If you have a usecase, please raise an issue.
MIT / Apache-2.0