Skipping the double "==" to check the comparison, "=" is the assignment operation.
if(jsonObject.Address == null) { return "null array"; }
Your JSON should look like this. Otherwise, you will not check for a null array, but instead an array with a null value for the first element of the array.
{ "Name": "Mike", "Personaldetails": [ { "Age": 25, "Surname": "Barnes" } ], "Address": null }
Then the code will look like this:
if(jsonObject.Address == null) { return "null array"; }
If you need to keep the original JSON, you can always do this:
if(jsonObject.Address.Length > 0 && jsonObject.Address[0] == null) { return "null array"; }
source share