title: How to correctly convert an NSDictionary to a json format , in iOS?
body: <p>I am trying to send to my server a json file. The json format should look exactly like this:</p>
  
  <pre><code>{
      "eventData": {
          "eventDate": "Jun 13, 2012 12:00:00 AM",
          "eventLocation": {
              "latitude": 43.93838383,
              "longitude": -3.46
          },
          "text": "hjhj",
          "imageData": "raw data",
          "imageFormat": "JPEG",
          "expirationTime": 1339538400000
      },
      "type": "ELDIARIOMONTANES",
      "title": "accIDENTE"
  }
  </code></pre>
  
  <p>I hardcoded this and worked like this:</p>
  
  <pre><code>NSString *jsonString = @"{\"eventData\":{\"eventDate\":\"Jun 13, 2012 12:00:00 AM\",\"eventLocation\":{\"latitude\":43.93838383,\"longitude\":-3.46},\"text\":\"hkhkjh\",\"imageData\":\"\",\"imageFormat\":\"JPEG\",\"expirationTime\":1339538400000},\"type\":\"Culture\",\"title\":\"accIDENTE\"}";
  </code></pre>
  
  <p>So i want to do the exact same thing but using an NSDictionary cause of course i dont want to hardcode all my data.
  So i am creating an NSDictionary like this:</p>
  
  <pre><code>NSMutableDictionary *eventLocation = [NSMutableDictionary dictionaryWithObjectsAndKeys:@"43.93838383",@"latitude",@"-3.46", @"longitude" , nil];
  
      NSMutableDictionary *eventData = [NSMutableDictionary dictionaryWithObjectsAndKeys:eventLocation,@"eventLocation", nil];
                          [eventData setObject:@"Jun 13, 2012 12:00:00 AM" forKey:@"eventDate"];
                          [eventData setObject:@"hjhj" forKey:@"text"];
                          [eventData setObject:@"raw data" forKey:@"imageData"];
                          [eventData setObject:@"JPEG" forKey:@"imageFormat"];
                          [eventData setObject:@"1339538400000" forKey:@"expirationTime"];
  
      NSMutableDictionary *finalDictionary = [NSMutableDictionary dictionaryWithObjectsAndKeys:eventData,@"eventData", nil];
                          [finalDictionary setObject:@"ELDIARIOMONTANES" forKey:@"type"];
                          [finalDictionary setObject:@"accIDENTE" forKey:@"title"];
  </code></pre>
  
  <p>Now i have to convert this to the correct json format , so that i can send it to my server.
  I tried using this :</p>
  
  <pre><code>NSError *error;
          NSData *jsonData = [NSJSONSerialization dataWithJSONObject:finalDictionary 
                                                             options:NSJSONWritingPrettyPrinted
                                                               error:&amp;error]
  </code></pre>
  
  <p>but now when i print the jsonData i get this :</p>
  
  <pre><code>jsonData: &lt;7b0a2020 22657665 6e744461 74612220 3a207b0a 20202020 22696d61 6765466f 726d6174 22203a20 224a5045 47222c0a 20202020 22746578 7422203a 2022686a 686a222c 0a202020 2022696d 61676544 61746122 203a2022 72617720 64617461 222c0a20 20202022 65787069 72617469 6f6e5469 6d652220 3a202231 33333935 33383430 30303030 222c0a20 20202022 6576656e 744c6f63 6174696f 6e22203a 207b0a20 20202020 20226c6f 6e676974 75646522 203a2022 2d332e34 36222c0a 20202020 2020226c 61746974 75646522 203a2022 34332e39 33383338 33383322 0a202020 207d2c0a 20202020 22657665 6e744461 74652220 3a20224a 756e2031 332c2032 30313220 31323a30 303a3030 20414d22 0a20207d 2c0a2020 22747970 6522203a 2022454c 44494152 494f4d4f 4e54414e 4553222c 0a202022 7469746c 6522203a 20226163 63494445 4e544522 0a7d&gt;
  </code></pre>
  
  <p>What is this exactly?? How can i just convert that dictionary to look exactly like this:</p>
  
  <pre><code>{
      "eventData": {
          "eventDate": "Jun 13, 2012 12:00:00 AM",
          "eventLocation": {
              "latitude": 43.93838383,
              "longitude": -3.46
          },
          "text": "hjhj",
          "imageData": "raw data",
          "imageFormat": "JPEG",
          "expirationTime": 1339538400000
      },
      "type": "ELDIARIOMONTANES",
      "title": "accIDENTE"
  }
  </code></pre>
  
  <p>If possible i want the above format to be an NSString cause that was what i was sending to the server and it was working. I mean an NSString , in json format like this.
  Thank you very much for bothering reading all this! :D</p>