Created
March 31, 2015 15:40
heka foo decoder
This file contains hidden or 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
local cjson = require("cjson") | |
function process_message() | |
local payload_str = read_message("Payload") | |
local ok, payload = pcall(cjson.decode, payload_str) | |
if not ok then | |
return -1 | |
end | |
payload["bar"] = read_message("Logger") | |
local ok, payload_with_bar = pcall(cjson.encode, payload) | |
if not ok then | |
return -1 | |
end | |
write_message("Payload", payload_with_bar) | |
return 0 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment