The application I am designing consumes JSON objects returned by PHP scripts that select from a SQL Server 2008 database. The problem I am encountering is that when the database is missing a value for a certain field, it returns as a null in JSON. Then when the app parses the JSON (I am using NSJSONSerialization), the dictionary contains a value. When using this dictionary to populate my view, the application crashes when encountering the null value.
What would be the easiest way to bypass this problem? I am thinking I could just replace all nulls with empty string before the PHP returns the data as JSON; however, that might not be the best solution. Is there a simple way to check in iOS?
Thanks for the help.
To check for null values you need to see if the object is
[NSNull null].