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/json2lua.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/json2lua.lua')
| -rwxr-xr-x | lua/json2lua.lua | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lua/json2lua.lua b/lua/json2lua.lua new file mode 100755 index 0000000..050b89d --- /dev/null +++ b/lua/json2lua.lua | |||
| @@ -0,0 +1,14 @@ | |||
| 1 | #!/usr/bin/env lua | ||
| 2 | |||
| 3 | -- usage: json2lua.lua [json_file] | ||
| 4 | -- | ||
| 5 | -- Eg: | ||
| 6 | -- echo '[ "testing" ]' | ./json2lua.lua | ||
| 7 | -- ./json2lua.lua test.json | ||
| 8 | |||
| 9 | local json = require "cjson" | ||
| 10 | local misc = require "cjson-misc" | ||
| 11 | |||
| 12 | local json_text = misc.file_load(arg[1]) | ||
| 13 | local t = json.decode(json_text) | ||
| 14 | print(misc.serialise_value(t)) | ||
