Questions tagged [nsjsonserialization]

NSJSONSerialization class is used to convert JSON to Foundation objects and Foundation objects to JSON

NSJSONSerialization class is used to convert JSON to Foundation objects and Foundation objects to JSON.

More information: NSJSONSerialization Class Reference

709 questions
3
votes
1 answer

FHSTwitterEngine - 'NSInvalidArgumentException','data parameter is nil'

I'm using FHSTwitterEngine to post a gif to twitpic. When I have a wifi or 3G connection on the iphone everything works fine. But I also want to implement some error handling for when there is no connection or when the upload failed. So for testing…
3
votes
1 answer

HTTP GET request working in iOS simulator but not on iPhone device

My app is calling a basic PHP script that outputs JSON data. I am calling my PHP script like this: NSString *buildURL = [NSString stringWithFormat: @"http://xxxx.com/api.php?action=authenticate_user&email=%@&password=%@&deviceToken=%@",…
Alosyius
  • 8,771
  • 26
  • 76
  • 120
3
votes
1 answer

Parse true and false values on a JSON string using NSJSONSerialization JSONObjectWithData:

I'm developing an iOS 5 and above application with latest SDK. I have to parse this JSON: {"GetHoroscope":false,"GetQuoteOfTheDay":false, ... } To do it, I have this code: - (NSDictionary*)getDictionaryFromNSData:(NSData*)jsonData { NSError*…
VansFannel
  • 45,055
  • 107
  • 359
  • 626
3
votes
2 answers

Parsing JSON with NSJSONSerialization: Error 3840 - Data Corrupted?

I've read many Q/As on this problem but couldn't find an answer that fits my situation. I retrieve a JSON response from a REST service I've created in PHP. This is my code: NSURLResponse *response = nil; NSError *theError1 = nil; NSError *theError2…
Thorsten Dittmar
  • 55,956
  • 8
  • 91
  • 139
3
votes
1 answer

how to post json data using AFnetworking or NSJsonserialization

I have used GET a number of time. but in current situation i have to use a webService using POST method. i have gone through many of the tutorials but unable to do. the path is "http://vinipost.com/Services/Mobile_Application/wcfService.svc/logIn"…
3
votes
3 answers

Mapping JSON objects in custom objects

I've been searching if it is possible to get a JSON dictionary or array and directly map it in a custom object whose properties have the same name as the JSON tags, but I din't find any information regarding that. I've been parsing JSON dictionaries…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
3
votes
3 answers

NSJSONSerialization returning null for MapQuest JSON in iOS

I am trying to parse a mapquest geocode json in iOS, but NSJSONSterilization returns null. I checked with online json checkers and it appears that the url is in fact a json. Here is the code for NSJSONSerialization if(geocodeResponseData) { …
Spenciefy
  • 892
  • 11
  • 33
3
votes
1 answer

Json parsing nil field in objective-c

I have a problem with mapping a JSON to a foundation object... Is there any way to put a "nil" value to a class member variable when the JSON string doesn't contain that key? Ex, here's my DataModel class: @interface DataModel : JSONModel @property…
Shinnyx
  • 2,144
  • 2
  • 14
  • 21
3
votes
1 answer

JSON to NSDictionary literal

I need to build an NSDictionary that I can then parse with NSJSONSerialization in order to get a nice JSON formatted string. The final output of my JSON needs to be something like: "Viewport":{ "BottomRight":{ …
Nic Hubbard
  • 41,587
  • 63
  • 251
  • 412
3
votes
1 answer

Issue with parsing JSON data

I am trying to convert a string into a json object and am unsure why this is not working. When I nslog the output I am told that urldata is not valid for json serialization however when looking at the string it looks to me like valid json. I have…
Jamesla
  • 1,378
  • 7
  • 31
  • 62
3
votes
2 answers

NSJSONSerialization unboxes NSNumber?

I'm using NSJSONSerialization to turn a JSON document into the Core Foundation types. I have a field in my JSON which is a "number". It's sometimes and integer, sometimes a float. Now, the problem is when NSJSONSerialization turns my JSON into an…
elsurudo
  • 3,579
  • 2
  • 31
  • 48
3
votes
1 answer

NSJSON Serialization

I am new to NSJSONSerialization. Here's my browser output: { "appointment": [ { "w1": "Mallya Hospital", "w2": "Nagarjuna Hospital", "w3": "Mallige Hospital", "w4": "Mallya Hospital", "t1": [ "08:00 -…
user1871889
  • 31
  • 1
  • 3
3
votes
1 answer

TWRequest code works but very slow to show?

I'm working with TWrequest to display my twitter lists in a tableview. The following code works. The problem is it is very slow to update the table. I am NSlogging the request response (which happens very quickly), I am also looping through each…
Andrew Davis
  • 2,310
  • 1
  • 24
  • 43
3
votes
1 answer

Initializing NSMutableArray __strong with an incompatible type of void

This is what is returning the error: NSMutableArray *newArray = [[[NSMutableArray alloc] initWithArray:[NSJSONSerialization JSONObjectWithData:[[[appDelegate.Matches objectAtIndex:(NSUInteger)indexPath] objectForKey:@"chat"]…
michaela
  • 173
  • 1
  • 2
  • 13
2
votes
3 answers

NSJSONSerialization gives me error "Duplicate key"

I request a JSON response from a home controlling device: NSData* responseData = [NSData dataWithContentsOfURL:url]; The JSON data in responseData is complete and valid. However, if I try NSDictionary* dict = [NSJSONSerialization …
Norbert
  • 4,239
  • 7
  • 37
  • 59