Skip to content

FauxFaux/lua2json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages