I'm having a bit of issue with a JSON service response. The service responds two different ways. i.e. rather then producing an error or a meaningful response it throws a another json format at you. Now most of the time this is okay however, there are times where Objective C just gives up because it hasn't handled the new structure (i.e. I am trying to program it to be handled).
I have a basic JSON call and return (Abstract).
NSArray *jsonArray = [[NSJSONSerialization JSONObjectWithData: data options: NSJSONReadingMutableContainers error: &e] mutableCopy];
When I call a service that provides detailed information I get the following format (No Error)
Printing description of jsonArray:
{
YBBN = {
charts = (
{
id = "5f0ec74a-6e7c-5484-aef2-5929b85d9739";
type = General;
},
When I call the same service that doesn't have data it provides the following structure producing a crash.
Printing description of jsonArray:
{
NZAA = 0;
}
I simply want to check the returning JSON if the charts node exists if it does continue on (these are not the droids your looking for) else throw up an error and handle the exception and stop crashing on the user.
I have tried different techniques but each one seems to either entirely skip the "check" or fails entirely.
I've gone back to the drawing board with this, surely there is a simple way of achieving a simple if statement to check. What am I missing?
Thanks in advance!