VB.Net JSON Is Nothing Not Working?
Question
item.Text = If(jResults2("items")("item") Is Nothing, "", jResults2("items")("item")("icon").ToString())
i am using this code to so if item is not present in the json it will continue however when the item does appear in the json it is still setting the "" value rather than the value provided by json
Solution
Your code looks fine. To inspect it more closely at runtime, try to run your application in debug mode, put breakpoint at that line of code. Then see in VS's watch window what value each of following expression returns :
jResults2("items")("item")
jResults2("items")("item") Is Nothing
jResults2("items")("item")("icon").ToString()
With that you can be sure what is happening. Train your debugging skill, that will help a lot.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow