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
-1
votes
2 answers

Error Domain=NSCocoaErrorDomain Code=3840 "Invalid escape sequence around character 746."

I am getting this error Error Domain=NSCocoaErrorDomain Code=3840 "Invalid escape sequence around character 746." UserInfo={NSDebugDescription=Invalid escape sequence around character 746.} Here is my code to parse JSON: NSString *strResponse =…
Krutarth Patel
  • 3,407
  • 6
  • 27
  • 54
-1
votes
1 answer

NSJSONSerialization converting NSDictionary to Hexadecimal

Im attempting to convert a NSDictionary to JSON using the NSJSONSerialization.dataWithJSONObeject function Code : do{ let jsonData = try NSJSONSerialization.dataWithJSONObject(SerializationHelper.toDictionary(user), options:…
mwild
  • 1,483
  • 7
  • 21
  • 41
-1
votes
2 answers

Convert NSString to JSON

I am converting a [NSDictionary] to NSString like so : do{ let newDict = try NSJSONSerialization.dataWithJSONObject(objectDictionaries, options: NSJSONWritingOptions.PrettyPrinted) if let json = NSString(data: newDict, encoding:…
Len_X
  • 825
  • 11
  • 29
-1
votes
1 answer

Exception in Access to JSONserialization with NSDictionary

I have a data from API Rest. I convert it to a NSArray with serialization and convert this to Dictionary. But I can't access to the pairs values (below). My first step: NSArray *arrayDiccionario = [NSJSONSerialization JSONObjectWithData:data…
-1
votes
3 answers

My swift app fail to convert NSData to Json

I was trying to convert NSData to Json by doing this: let jdata = getJSON("https://api.myjson.com/bins/16j2i") do { let json = try NSJSONSerialization.JSONObjectWithData(jdata, options: []) as! [String: AnyObject] …
Joey Zhang
  • 363
  • 6
  • 18
-1
votes
1 answer

NSJSONSerialization fails while casting into Dictionary. Succeeds while casting into Dictionary

I am trying to Parse a json. Casting to [String,AnyObject?] fails. while [String,AnyObject] succeeds if let jsonDictionary = try! NSJSONSerialization.JSONObjectWithData(responseData, options: NSJSONReadingOptions.MutableContainers) as?…
sparrowceg
  • 81
  • 6
-1
votes
2 answers

How to convert an NSString of JSON objects to an NSArray?

I'm having trouble converting my NSString of JSON objects to an NSArray. The NSArray object seems to be null. Here is my NSString JSON code: NSString* retrievedStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; This gives me…
Pangu
  • 3,721
  • 11
  • 53
  • 120
-1
votes
1 answer

How to generate JSON data from NSDictionary in Swift

I'm new to Swift and I am trying to generate JSON data from an NSDictionary Here's my code: func metricsToJson() { if let data = NSJSONSerialization.dataWithJSONObject(metricsData, options: NSJSONWritingOptions.PrettyPrinted, error: &error)…
Varun Varahabotla
  • 548
  • 2
  • 7
  • 16
-1
votes
2 answers

I am having trouble parsing JSON that is returned from the NSURL session. What am I doing wrong?

I'm successfully making a POST request and getting data back in return. I can then print that statement in the form of an NSString, after converting of course. However, I want to save the returned json in usable variables/constants so I can display…
petermaxstack
  • 325
  • 1
  • 3
  • 10
-1
votes
1 answer

JSONSerilazation not working while parsing JSON object

I am getting an error while parsing the NSData I got from a server. I am unable get the NDIctinory. I am getting the error "No string key for value in object" NSDictionary* json = [NSJSONSerialization JSONObjectWithData:[body…
KAREEM MAHAMMED
  • 1,675
  • 14
  • 38
-1
votes
1 answer

iOS : NSJSONSerialization: Wrong code or wrong JSON structure?

I have some trouble with parsing my JSON object for the past 6 hours. In my code, I stripped a JSON response from server (which has been saved as a NSData object) using the following method: NSMutableDictionary * responseDataRaw =…
Marcus
  • 548
  • 1
  • 5
  • 13
-1
votes
1 answer

Json to iOS Encoding Error

Problem: I can't parse data from a JSON file to a NSArray appropriately. UTF encoding is not working as expected. My JSON looks something like: [ {"Name":"Marcos","Address":"1234 Brasil Av. São Paulo -…
-1
votes
1 answer

NSJSONSerialization issues. Incorrect JSON object sent to api

In my xcode project I'm sending a post request with json data to my api using the Unirest library: NSDictionary *jsonObj = @{@"access_token": accessToken}; UNIHTTPJsonResponse* response = [[UNIRest postEntity:^(UNIBodyRequest* request) { …
jeh
  • 2,373
  • 4
  • 23
  • 38
-1
votes
1 answer

IOS Development, Unable to convert my NSData to NSJSONSerialization JSONObjectWithData:

Here is the below code I edited. Please help me out. I was trying to display the data in list view. NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; NSData *urlData=[NSURLConnection…
user3440782
  • 144
  • 1
  • 14
-1
votes
1 answer

How to parse JSON response received from a Webservice Response

I Have got this Response from WebService {"d":"{"token":"b502645e-837f-4237-a6ff-d4323f2799dd","timestamp":"09/11/20147:46:43PM"}"} I want to Parse this String so that i can get output like : token = b502645e-837f-4237-a6ff-d4323f2799dd …
Asmi237
  • 33
  • 8