title: Invalid value around character 0, NSJSONSerialization
body: <p>I make a get from my server and I get a valid response:</p>
  <pre><code>- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
      // Append the new data to the instance variable you declared
      
      
      //[_responseData appendData:data];
      
      NSString *responseBody = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
      NSLog(@&quot;%@&quot;,responseBody);
      
      if(data != NULL)
      {
          dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,
                                                   (unsigned long)NULL), ^(void) {
          
          NSError *error = nil;
          //NSMutableArray *jsonArray = [[CJSONDeserializer deserializer] deserializeAsArray:[responseBody dataUsingEncoding:NSUTF8StringEncoding] error:&amp;error];
              NSMutableArray *jsonArray = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:&amp;error];
          if (error)
          {
              NSLog(@&quot;JSONObjectWithData error: %@&quot;, error);
              [delegate onErrorGetArrayFromServer];
          }
          else
          [self parseJSON:jsonArray];
          
          });
          
      }
      else
      {
          if([delegate respondsToSelector:@selector(onErrorGetArrayFromServer)])
          {
              [delegate onErrorGetArrayFromServer];
          }
      }
  }
  </code></pre>
  <h3>The response is like:</h3>
  <pre><code>[{
          &quot;id&quot;: &quot;37&quot;,
          &quot;id_estado&quot;: &quot;1&quot;,
          &quot;id_categoria&quot;: &quot;1&quot;,
          &quot;nombre&quot;: &quot;fer&quot;,
          &quot;email&quot;: &quot;asd@gmail.com&quot;,
          &quot;fecha&quot;: &quot;2014-07-16 11:25:00&quot;,
          &quot;observaciones&quot;: &quot;as dasd asdasd sasd&quot;,
          &quot;latitud&quot;: &quot;37.619636&quot;,
          &quot;longitud&quot;: &quot;-4.318449&quot;,
          &quot;foto&quot;: &quot;images\/default.jpg&quot;
      },
  
      {
          &quot;id&quot;: &quot;36&quot;,
          &quot;id_estado&quot;: &quot;1&quot;,
          &quot;id_categoria&quot;: &quot;6&quot;,
          &quot;nombre&quot;: &quot;Fernando&quot;,
          &quot;email&quot;: &quot;&quot;,
          &quot;fecha&quot;: &quot;2014-07-16 10:32:45&quot;,
          &quot;observaciones&quot;: &quot;que&quot;,
          &quot;latitud&quot;: &quot;37.6178690439634&quot;,
          &quot;longitud&quot;: &quot;-4.3238141387701&quot;,
          &quot;foto&quot;: &quot;images\/default.jpg&quot;
      }
   ]
  </code></pre>
  <p>###It throws me the error:###</p>
  <pre><code>JSONObjectWithData error: Error Domain=NSCocoaErrorDomain Code=3840 &quot;The operation couldn’t be completed. (Cocoa error 3840.)&quot; (Invalid value around character 0.) UserInfo=0x9e0f610 {NSDebugDescription=Invalid value around character 0.}
  </code></pre>
  <p>I tried with other library (<strong>CJSON</strong>) and it throw me the error:</p>
  <pre><code>JSONObjectWithData error: Error Domain=kJSONScannerErrorDomain Code=-202 &quot;Could not scan array. Could not scan a value.&quot; UserInfo=0xa15c0e0 {snippet=!HERE&gt;![{&quot;id&quot;:&quot;37&quot;,&quot;id_esta, location=0, NSLocalizedDescription=Could not scan array. Could not scan a value., character=0, line=0}
  </code></pre>
  <p><em>My server is a REST server and for my Android aplication works well.</em></p>
  <hr />
  <p><em><strong><em>SOLVED</em></strong></em></p>
  <p>Thanks to @Himanshu Joshi:</p>
  <p><em>Why are you parsing the data in didReceiveData:? Data is not downloaded completely there, you have to append the data there. Parse the data in connectionDidFinishLoading: delegate method –</em></p>
  <p>I parsed the data in <code>connectionDidFinishLoading:</code> and everything go fine.</p>