Does the openresty installation have any json validator for lua? the cjson.decode just blows up and the cjson library does not seem to have a validation method for json?Do i have to use some other open source libs written for Lua for JSON validation? .
That was exactly what I needed. Thanks so much. :)
Hi,cjson.decode will give you some hints in an error string if you call using pcall. If you just want to ensure it doesn't blow up at run time, pcall is definitely all you need: http://www.lua.org/manual/5.1/manual.html#pdf-pcalllocal ok, res = pcall(cjson.decode, json)'ok' will either be true of false, and 'res' will either be the return value or an error string.James.On 22 September 2014 15:27, Samarjit Uppal <uppal...@gmail.com> wrote:Does the openresty installation have any json validator for lua? the cjson.decode just blows up and the cjson library does not seem to have a validation method for json?Do i have to use some other open source libs written for Lua for JSON validation? . smk Hi Samarjit, I am looking for a lua based json validator too. Would be great if you could post the sample code you got working. Thanks in advance,On Monday, September 22, 2014 at 11:44:14 AM UTC-5, Samarjit Uppal wrote:That was exactly what I needed. Thanks so much. :) On 22-Sep-2014 8:28 pm, "James Hurst" <ja...@pintsized.co.uk> wrote:Hi,cjson.decode will give you some hints in an error string if you call using pcall. If you just want to ensure it doesn't blow up at run time, pcall is definitely all you need: http://www.lua.org/manual/5.1/manual.html#pdf-pcalllocal ok, res = pcall(cjson.decode, json)'ok' will either be true of false, and 'res' will either be the return value or an error string.James.On 22 September 2014 15:27, Samarjit Uppal <uppal...@gmail.com> wrote:Does the openresty installation have any json validator for lua? the cjson.decode just blows up and the cjson library does not seem to have a validation method for json?Do i have to use some other open source libs written for Lua for JSON validation? .
That was exactly what I needed. Thanks so much. :) On 22-Sep-2014 8:28 pm, "James Hurst" <ja...@pintsized.co.uk> wrote:Hi,cjson.decode will give you some hints in an error string if you call using pcall. If you just want to ensure it doesn't blow up at run time, pcall is definitely all you need: http://www.lua.org/manual/5.1/manual.html#pdf-pcalllocal ok, res = pcall(cjson.decode, json)'ok' will either be true of false, and 'res' will either be the return value or an error string.James.On 22 September 2014 15:27, Samarjit Uppal <uppal...@gmail.com> wrote:Does the openresty installation have any json validator for lua? the cjson.decode just blows up and the cjson library does not seem to have a validation method for json?Do i have to use some other open source libs written for Lua for JSON validation? .
Hi,cjson.decode will give you some hints in an error string if you call using pcall. If you just want to ensure it doesn't blow up at run time, pcall is definitely all you need: http://www.lua.org/manual/5.1/manual.html#pdf-pcalllocal ok, res = pcall(cjson.decode, json)'ok' will either be true of false, and 'res' will either be the return value or an error string.James.On 22 September 2014 15:27, Samarjit Uppal <uppal...@gmail.com> wrote:Does the openresty installation have any json validator for lua? the cjson.decode just blows up and the cjson library does not seem to have a validation method for json?Do i have to use some other open source libs written for Lua for JSON validation? .