clone of Mark Pulford's lua-cjson, but minimal fixes.