lua2json

Crates.iolua2json
lib.rslua2json
version0.1.0
sourcesrc
created_at2023-02-20 17:58:17.785477
updated_at2023-02-20 17:58:17.785477
descriptionA Lua parser that outputs JSON
homepage
repositoryhttps://github.com/FauxFaux/lua2json
max_upload_size
id790044
size12,236
Chris West (FauxFaux)

documentation

README

lua2json

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.

License

MIT / Apache-2.0

Commit count: 9

cargo fmt