title: Remove quotes from JSON and replace curly brackets with square brackets
body: <p>I am trying to create an array of data for use with a <a href="http://www.flotcharts.org/" rel="nofollow">FLOT</a> chart.  I am using this CodeIgniter code to generate the array:</p>
  
  <pre><code>function ajaxmuniChart1c(){
  $muni = $this-&gt;input-&gt;POST('muni');
  $q = $this-&gt;db-&gt;query("SELECT SaleYear AS Y, NewSaleType AS T, count(*) AS C, format((sum(SalePrice) / sum(Quantity1)),0) AS R FROM tblsales WHERE  tblsales.SaleYear &gt; 2007 AND tblsales.Quantity1 &gt; 2000 AND (tblsales.NewSaleType = 'Industrial') AND tblsales.Municipality = '".$muni."' GROUP BY T,Y ORDER BY T,Y");
  $json_Array    = array();
  foreach ($q-&gt;result_array() as $row){
      $JsonArray[] = array( floatval($row['Y']) =&gt; floatval($row['R']) );
  }
  $labeledArray = array( 
      "label" =&gt; "Average Sale Price per SF",
      "data" =&gt; $JsonArray
  );
  echo json_encode($labeledArray);
  exit;
  }
  </code></pre>
  
  <p>The problem with this code is that the resulting JSON object cannot be plotted because the "values" are in fact strings.  Here is the problematic JSON output:</p>
  
  <pre><code> {"label":"Average Price","data":[{"2008":96},{"2009":74},{"2010":73},{"2011":96},{"2012":124},{"2013":104}]}
  </code></pre>
  
  <p>There are three problems with this JSON:  </p>
  
  <ol>
  <li>Need square brackets instead of curly brackets; and </li>
  <li>Need to use commas to separate the key->value pair instead of full-colon; and</li>
  <li>Quotes need to be removed so that the string "2008" becomes the value 2008.</li>
  </ol>
  
  <p>Here is the way the JSON output needs to be formatted:</p>
  
  <pre><code> ["label":"Average Price","data":[[2008,96],[2009,74],[2010,73],[2011,96],[2012,124],[2013,104]]]
  </code></pre>
  
  <p>What is the best way to clean-up this JSON object?  Should I do it on the server side with the CodeIgniter code?  Or should I do it on the client side in javascript after the JSON object has been made?  Thanks.</p>