diff options
author | Mark Pulford <mark@kyne.com.au> | 2012-01-13 07:17:48 +1030 |
---|---|---|
committer | Mark Pulford <mark@kyne.com.au> | 2012-03-04 18:54:34 +1030 |
commit | 5fb9fe1c67a070d1e83497c44b7b7364da9f1975 (patch) | |
tree | 861deaac983fcc04801e1f9f645f3dc7729f773b /lua/lua2json.lua | |
parent | 3871cb71c858b8e542b78677f782b88ddd820cb3 (diff) | |
download | lua-cjson-5fb9fe1c67a070d1e83497c44b7b7364da9f1975.tar.gz lua-cjson-5fb9fe1c67a070d1e83497c44b7b7364da9f1975.tar.bz2 lua-cjson-5fb9fe1c67a070d1e83497c44b7b7364da9f1975.zip |
Move cjson-misc and scripts to "lua" directory
Diffstat (limited to 'lua/lua2json.lua')
-rwxr-xr-x | lua/lua2json.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lua/lua2json.lua b/lua/lua2json.lua new file mode 100755 index 0000000..2a9ddf9 --- /dev/null +++ b/lua/lua2json.lua | |||
@@ -0,0 +1,20 @@ | |||
1 | #!/usr/bin/env lua | ||
2 | |||
3 | -- usage: lua2json.lua [lua_file] | ||
4 | -- | ||
5 | -- Eg: | ||
6 | -- echo '{ "testing" }' | ./lua2json.lua | ||
7 | -- ./lua2json.lua test.lua | ||
8 | |||
9 | local json = require "cjson" | ||
10 | local misc = require "cjson-misc" | ||
11 | |||
12 | local env = { | ||
13 | json = { null = json.null }, | ||
14 | null = json.null | ||
15 | } | ||
16 | |||
17 | local t = misc.run_script("data = " .. misc.file_load(arg[1]), env) | ||
18 | print(json.encode(t.data)) | ||
19 | |||
20 | -- vi:ai et sw=4 ts=4: | ||