0

I trying to use lua cjson to parse to following json :

 {
       "data" : null,
         "message" : "Your session has expired. Please login again.",
           "code" : "390112",
             "success" : false
 }

it's parsed to the following map :

{ ["message"] = Your session has expired. Please login again.,["success"] = false,["data"] = userdata: (nil),["code"] = 390112,}

and i trying to to do something like:

if decoded["data"] == nil or decoded["data"] ==userdata(nil)  then
  return 
end

is that possible?

(userdata(nil) is not valid expression )

Eyal leshem
  • 995
  • 2
  • 10
  • 21
  • Your examples don't make sense to me. Please provide a [mcve]. Userdata cannot be nil. userdata an nil are two different types. userdata type values cannot be (de-)serialized by lua-cjson. – Piglet Jan 27 '20 at 08:26
  • but when i dump the response this is the answer "["data"] = userdata: (nil)" – Eyal leshem Jan 27 '20 at 08:43
  • 3
    use `cjson.null`. It is zero lightuserdata. You can not create it from Lua. Only via C API – moteus Jan 27 '20 at 08:47

0 Answers0