json2lua.lua 304 B

123456789101112131415
  1. #!/usr/bin/env lua
  2. -- usage: json2lua.lua [json_file]
  3. --
  4. -- Eg:
  5. -- echo '[ "testing" ]' | ./json2lua.lua
  6. -- ./json2lua.lua test.json
  7. local json = require "cjson"
  8. local util = require "cjson.util"
  9. local json_text = util.file_load(arg[1])
  10. local t = json.decode(json_text)
  11. print(util.serialise_value(t))