Created
August 29, 2015 14:23
-
-
Save narate/c9299b4bc60828e1c95e to your computer and use it in GitHub Desktop.
Just one line json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env luajit | |
-- author : Narate Ketram | |
-- github.com/narate | |
-- usage : | |
--[[ | |
echo ' | |
{ | |
"query": { | |
"bool": { | |
"must": [ | |
{ | |
"term": { | |
"plugin": "interface" | |
} | |
}, | |
{ | |
"term": { | |
"uid": 1113 | |
} | |
} | |
] | |
} | |
} | |
} | |
' | one_line_json | |
{"query":{"bool":{"must":[{"term":{"plugin":"interface"}},{"term":{"uid":1113}}]}}} | |
--]] | |
local cjson = require 'cjson.safe' | |
local data = io.read('*all') | |
local json = cjson.decode(data) | |
if not json then | |
print('Invalid json') | |
return | |
end | |
print(cjson.encode(json)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment