title: Cannot Decode JSON API response
body: <p>I have built an API for my shipping quote system. I feed it values and I get rate quotes back. It works fine but I cannot decode the JSON response. I get a NULL response and I'm not sure whats up. According to validaters the JSON is correct.</p>
  
  <p>So what I essentially do is encode a PHP array on one side and I want to parse that on the other side using a browser and PHP. However, I get a NULL response.</p>
  
  <p>Here is the JSON. Let me know if you need more.</p>
  
  <pre><code>{"carrier":"R&amp;L Carriers","charge":"99.13","service_days":"Wednesday Oct. 22, 2014"}
  </code></pre>
  
  <p>I just want to decode this so I can parse it. If there is another way to parse please let me know.</p>
  
  <p>Also, I searched SOF and the similar issues people were having here didn't help me.</p>
  
  <p>This is the code I use to generate the JSON.</p>
  
  <pre><code>    &lt;?php
      //include ('mysql_connect.php');
  
      $result = mysql_query('select * from quote where user_id = "'.$user_id.'" order by netCharge asc limit 1');
  
      if (!$result) {
          die('Could not query:' . mysql_error());
      }
  
      if (!$result) echo mysql_error();
  
      $api_data = array();
      $api_count = '0';
      while ($row = mysql_fetch_array($result, MYSQLI_ASSOC)) {
  
      $api_data[carrier] = $row['carrier'];
      $api_data[charge] = $row['netCharge'];
      $api_data[service_days] = $row['serviceDays'];
  
      $api_count++;
  
      }
  
      $api_data = json_encode($api_data);
  
      print_r($api_data);
  
      ?&gt;
  </code></pre>
  
  <p>This is what I'm using to grab that JSON data:</p>
  
  <pre><code>    &lt;?php
  
      $input = file_get_contents('api_request.php?dest_zip=66101&amp;weight=200&amp;class=50&amp;ltl_shipment=X&amp;Residential_Delivery=X');
      echo $input;
  
      $obj = json_decode($input);
      var_dump($obj);
  
      ?&gt;
  </code></pre>