title: NSJSONSerialization generating NSCFString* and NSTaggedPointerString*
body: <p>Executing NSJSONSerialization on the following json sometimes gives me NSCFString* and sometimes NSTaggedPointerString* on string values.  Does anyone know why this is the case and what NSJSONSerialization uses to determine which type it returns?</p>
  
  <pre><code>jsonData = [NSJSONSerialization JSONObjectWithData:data
                                                     options:kNilOptions
                                                       error:&amp;parseError];
  
      {
        "UserPermissionsService": {
          "ServiceHeader": {}, 
          "UserApplicationPermissions": {
            "ApplicationPermissions": {
              "ApplicationID": "TEST", 
              "Permission": [
                {
                  "Locations": [
                    "00000"
                  ], 
                  "PermissionID": "LOGIN"
                }, 
                {
                  "Locations": [
                    "00000"
                  ], 
                  "PermissionID": "SALES_REPORT_VIEW"
                }
              ]
            }
          }
        }
      }
  </code></pre>
  
  <p>"LOGIN" comes back as a NSTaggedPointerString*.  "SALES_REPORT_VIEW" comes back is a NSCFString*.  This is having an impact downstream where I'm using and casting the values.</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Here's what I learned...</p>
  
  <p>"NSTaggedPointerString results when the whole value can be kept in the pointer itself without allocating any data."</p>
  
  <p>There's a detailed explanation here...</p>
  
  <p><a href="https://www.mikeash.com/pyblog/friday-qa-2015-07-31-tagged-pointer-strings.html">https://www.mikeash.com/pyblog/friday-qa-2015-07-31-tagged-pointer-strings.html</a></p>
  
  <p>Since NSTaggedPointerString is a subclass of NSString showing quotes / not showing quotes should never been an issue for me as the data is used.</p>
  
  <p>Thanks for everyone that commented.  I'm comfortable I understand what NSJSONSerialization is doing.</p>