Closed alex-roman closed 8 years ago
Decode is failing since "Just a string" is not a JSON string - it needs quotes. Eg:
'"Just a string"'
"\"Just a string\""
If you need to capture the error from invalid requests you can use cjson.safe
. Eg:
local cjson_safe = require "cjson.safe"
result, err = cjson.safe("invalid json")
err
will be nil on success, or contain the error message.
The manual has further details.
Thank you! Exactly what I need!
Hi there!
First of all thank you for a library! Here is some code I can't explain to myself:
Some my clients send wrong JSON and it cause crash of script. If it's a correct behavior I'll be happy to know how can I handle this error?