title: Converting a JSON string into NSDictionary
body: <p>I'm trying to build an app in which people can order goods from different stores. I am totally new to programming, and I thought building a project like this would be a good way to learn it.</p>
  
  <p>I'm stuck at the part of my app where a user can search for a company (on company name, location, or both) in my database. The database returns a JSON string, containing the company name and location for all found companies, which looks like this:</p>
  
  <pre><code>{"companyName":"testcompany_1","companyCity":"Tiel"},  
  {"companyName":"tectcompany_2","companyCity":"Tiel"}
  </code></pre>
  
  <p>So far so good!</p>
  
  <p>now I want to turn this JSON string, which is an <code>NSString</code>, into an <code>NSDictionary</code>, in order to display the names and locations of the found companies in a <code>tableView</code>. This is where I get stuck.</p>
  
  <p>I have been searching through StackOverflow, google, etcetera, and I have tried several ways to do this, for example:</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/16129433/convert-nsstring-to-nsdictionary-separated-by-specific-character">Convert NSString to NSDictionary separated by specific character</a></li>
  <li><a href="https://stackoverflow.com/questions/5038371/convert-json-feed-to-nsdictionary">Convert JSON feed to NSDictionary</a></li>
  </ul>
  
  <p>Since none of the tutorials/answers is saw really solves my problem, I tried to make something out of them myself, and this is the result of that:</p>
  
  <pre><code>NSString *strURL = [NSString stringWithFormat:@"http://www.imagine-app.nl/companySearch.php?companyNameSearchField=%@&amp;companyCitySearchField=%@", companyNameSearchField.text, companyCitySearchField.text];
  NSData *dataURL = [NSData dataWithContentsOfURL:[NSURL URLWithString:strURL]];
  strResult = [[NSString alloc] initWithData:dataURL encoding:NSUTF8StringEncoding];
  NSArray *companies = [inputString componentsSeparatedByString:@"},{"];
  NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:[NSData dataWithContentsOfFile:companies] options:kNilOptions error:nil];
  </code></pre>
  
  <p>To me, this makes sense. First, turn an <code>NSString</code> into an <code>NSArray</code> to separate objects, and after that convert the string into an <code>NSDictionary</code>, which can be used by the <code>tableview</code> I want to populate with this. 
  But when I log the dictionary, it says <code>null</code>, so no <code>NSDictionary</code> seems to be made by this code.</p>
  
  <p>Now after several weeks of trying and searching, i'm starting to feel pretty stupid and desperate because I cannot find a good way to do this.</p>
  
  <p>Does anyone know bow to turn a <code>json string</code> as shown above, into an <code>NSDictionary</code>?</p>