I am using cjson
to decode the following JSON. I want to test for the case that the items parameter is null. I am having difficulty finding a conditional to match this case. It's weird because it seems like it is not a string, not nil, but stil has a truthy value.
{
"kind": "ServiceList",
"apiVersion": "v1",
"metadata": {
"selfLink": "/api/v1/services",
"resourceVersion": "47316"
},
"items": null
}
Here are the conditionals that I have tried:
if jsonServices.items == "null" then
if jsonServices.items == null then
if not jsonServices.items then
if jsonServices.items == nil
found this in the Lua docs
if jsonServices.items == cjson.null then
works great!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With