I am trying to parse some json and for some reason the table returned from decode is always nil. Maybe something wrong with the json string but it seems correct. Can anyone tell me what I am doing wrong ?
Here is the config for reference:
load_module modules/ndk_http_module.so;
load_module modules/ngx_http_lua_module.so;
# takes advantage of all the cores in a processor
worker_processes auto;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
root /data/www;
location / {
content_by_lua '
local cjson = require("cjson")
json_text = [[ [{ "message": "somewhere over the rainbow", "key": "7F02D18E-88E7-486D-B51F-550118491CB1"}] ]]
value = cjson.decode(json_text)
say(cjson.encode(value)) -- returns nil ?
ngx.say( value["message"] )
';
resolver 8.8.8.8;
}