1 unstable release
0.1.0 | Feb 20, 2023 |
---|
#2532 in Parser implementations
10KB
239 lines
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
Dependencies
~2–2.8MB
~52K SLoC