The difference between {"error":"The operation failed"}
and [{"id":"29"}]
:
the first one is Object (an unordered collection of key:value pairs with the ':' character separating the key and the value, comma-separated and enclosed in curly braces; the keys must be strings and should be distinct from each other);
the second one is Array (an ordered sequence of values, comma-separated and enclosed in square brackets; the values do not need to be of the same type).
In your app, you handle JSON response in Dictionary - which suits for {"error":"The operation failed"}
case, but is wrong for second case (which is an array) - [{"id":"29"}]
.
(With dictionary you can execute - objectForKey:
, and with array - objectAtIndex:
).
To understand, how it works, you can read more about JSON:
http://en.wikipedia.org/wiki/JSON