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
0
votes
4 answers

What would be more efficient to load content on a detail view from a view controller with a table view?

What would be more efficient to load content on a detail view from a view controller with a table view? Should I pass the variables over to the detail view from the didSelectRowAtIndexPath: method or is it better to make a JSON call to the server…
user2588945
  • 1,681
  • 6
  • 25
  • 38
0
votes
1 answer

JSON Parsing results in unrecognized selector sent

I am trying to parse the following with my JSON parser. I tried several ways but the actual JSON Serialization NSJSONSerialization always throws the error (well actually it is thrown on the NSArray *termArray = [dataDictionary…
renesteg
  • 551
  • 1
  • 9
  • 24
0
votes
1 answer

Converting NSMutableDictionary to JSON with NSJSONSerialization returns different results

When I try to convert NSMutableDictionary to JSON with NSJSONSerialization it returns different results: Code: -(NSString*)JSONRepresentation{ return [self JSONRepresentation:NO]; } -(NSString*)JSONRepresentation:(BOOL)whiteSpaces{ …
Cyprian
  • 9,423
  • 4
  • 39
  • 73
0
votes
1 answer

Objective C: Trying to create a JSON String with a Dictionary of NSArrays, NSDictionaries and custom objects

I am trying to create a JSON String out of a number of objects. Basically I am doing this to send up a portion of the database back to the server so it can update what has been done since it was last connected. I was hoping to be able to convert…
DaveB
  • 181
  • 3
  • 11
0
votes
1 answer

Serializing a custom object into NSDictionary or NSArray to use NSJSONSerialization

I've been looking for a way to serialize custom objects with NSJSONSerialization avoiding the use of third-party libraries, and I couldn't find any example. Is there any way of "automatically" create an NSDictionary and NSArray from an object,…
AppsDev
  • 12,319
  • 23
  • 93
  • 186
0
votes
3 answers

Determine which time is next from a list of times

I have a JSON request which gives prayer times. How can I use Objective-C to work out which is next? The JSON looks like this: { address = ""; city = ""; country = UK; "country_code" = GB; daylight = 1; for =…
samiles
  • 3,768
  • 12
  • 44
  • 71
0
votes
4 answers

How to refactor code so it's not on the main thread

I'm trying to refactor some NSJSONSerialization code so that it is not on the main thread. At the moment the app is a bit sluggish. I would like to refactor this code to what I have below and am having problems with the syntax particularly with the…
hanumanDev
  • 6,592
  • 11
  • 82
  • 146
0
votes
4 answers

How to request JSON data in the viewDidAppear method or viewDidLoad?

If I call the [self requestData]; from viewDidLoad my table populates itself with data just fine. If I move [self requestData]; to the viewDidAppear method the table remains empty. Also, I'm not entirely sure if [self.mainTableView reloadData];…
hanumanDev
  • 6,592
  • 11
  • 82
  • 146
0
votes
1 answer

Cannot parsing Json to NSDictionary

I have a WebService, which give me the fallowing Json-String back: "{\"password\" : \"1234\", \"user\" : \"andreas\"}" I call the webservice and try to parse the returned data like: [NSURLConnection sendAsynchronousRequest: request …
BennoDual
  • 5,865
  • 15
  • 67
  • 153
0
votes
1 answer

JSON format and objective-c

My app needs to submit a JSON payload to a server, the server wants the format like so: { "recipient_emails" :["test@xyz.net", "user@xyz.com"] } All I can seem to create is this format: { "recipient_emails" = ("test@xyz.net",…
random
  • 8,568
  • 12
  • 50
  • 85
0
votes
1 answer

Serialize JSON without wrapping in [ ]

I am trying to make an HTTP PUT request to a CouchDB server. I am converting an NSString instance to NSData. I then convert this NSData instance to an NSArray and attempt to PUT this to CouchDB. So something like this: //convert string to NSData …
Nick
  • 19,198
  • 51
  • 185
  • 312
0
votes
2 answers

iOS app crashing if data is inaccessible

I'm using the following to request data using NSJSONSerialization. The problem I'm having is that if the data is inaccessible (e.g. no network connection) the app crashes. How could I go about stopping the app from crashing if the network or server…
hanumanDev
  • 6,592
  • 11
  • 82
  • 146
0
votes
2 answers

How to output data using NSJSONSerialization?

I'm trying to output some data using NSJSONSerializationusing the code below. This log statement works NSLog(@"publicData: %@", publicData); but then it crashes when I try to get the "description" of the dictionary NSLog(@"data: %@",…
hanumanDev
  • 6,592
  • 11
  • 82
  • 146
0
votes
1 answer

How to resolve multiple NSURLconnection with separated data

I have 2 separate NSURLConnection. NSURLConnection * connection_users; NSURLConnection * connection_cards; Then i created the data with parameters, etc. and I finish with: connection_users = [[NSURLConnection alloc] initWithRequest:…
0
votes
1 answer

iphone - return fbid to use it in json web service to receive data

I've been looking around, saw similar posts, but nothing like this that could give me answers. This is my setup and flow of the app: User has to login via Facebook, using Facebook Graph. LoginView is presented modally, non animated When user…
SasaT
  • 731
  • 6
  • 19