We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Based on comment in source code https://github.com/nodemcu/nodemcu-firmware/blob/dev/app/modules/cjson.c I trying compare NULL from JSON response, but I always getting "false" even using suggested compare with cjson.null one.
return True
returns false
json_null_test = cjson.decode('null') print (json_null_test == cjson.null) false
print (json_null_test) userdata: 0x00000000
print (cjson.null) nil
NodeMCU 1.5.4.1+petrkr build 20161101 powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32) based on NodeMCU - branch dev commit f0780e3
NodeMCU Devkit 1.0 with ESP-12
The text was updated successfully, but these errors were encountered:
Found workaround for this issue:
cjson_null = cjson.decode('null') -- Define NULL object for compare json_null_test = cjson.decode('null') -- Parse real JSON print (json_null_test == cjson_null) -- Compare with local variable true
so I can use aswell in more complex JSON's
cjson_null = cjson.decode('null') json_null_test = cjson.decode('{ "var1": "Test var string1", "null_var": null }') print (json_null_test.null_var == cjson_null) true
Sorry, something went wrong.
The new sjson module has an explicit sjson.NULL symbol which contains the null value in use.
sjson
sjson.NULL
No branches or pull requests
Based on comment in source code https://github.com/nodemcu/nodemcu-firmware/blob/dev/app/modules/cjson.c
I trying compare NULL from JSON response, but I always getting "false" even using suggested compare with cjson.null one.
Expected behavior
return True
Actual behavior
returns false
Test code
NodeMCU version
NodeMCU 1.5.4.1+petrkr build 20161101 powered by Lua 5.1.4 on SDK 1.5.4.1(39cb9a32) based on NodeMCU - branch dev commit f0780e3
Hardware
NodeMCU Devkit 1.0 with ESP-12
The text was updated successfully, but these errors were encountered: