title: Passing a large dataset to the client - Javascript arrays or JSON?
body: <p>I'm passing a table of up to 1000 rows, consisting of name, ID, latitude and longitude values, to the client.</p>
  
  <p>The list will then be processed by Javascript and converted to markers on a Google map.</p>
  
  <p>I initially planned to do this with JSON, as I want the code to be readable and easy to deal with, and because we may be adding more structure to it over time.</p>
  
  <p>However, my colleague suggested passing it down as a Javascript array, as it would reduce the size greatly.</p>
  
  <p>This made me think, maybe JSON is a bit redundant. After all, for each row defined, the name of each field is also being outputted repetitively. Whereas, for an array, the position of the cells is used to indicate the field.</p>
  
  <p>However, would there really be a performance improvement by using an array?</p>
  
  <p>The site uses GZIP compression. Is this compression effective enough to take care of any redundancy found in a JSON string?</p>
  
  <p><strong>[edit]</strong></p>
  
  <p>I realize JSON is just a notation.</p>
  
  <p>But my real question is - what notation is best, performance-wise?</p>
  
  <p>If I use fully named attributes, then I can have code like this:</p>
  
  <pre><code>var x = resultset.rows[0].name;
  </code></pre>
  
  <p>Whereas if I don't, it will look less readable, like so:</p>
  
  <pre><code>var x = resultset.rows[0][2];
  </code></pre>
  
  <p>My question is - would the sacrifice in code readability be worth it for the performance gains? Or not?</p>
  
  <hr>
  
  <p>Further notes:</p>
  
  <p>According to Wikipedia, the Deflate compression algorithm (used by gzip) performs 'Duplicate string elimination'. <a href="http://en.wikipedia.org/wiki/DEFLATE#Duplicate_string_elimination" rel="nofollow noreferrer">http://en.wikipedia.org/wiki/DEFLATE#Duplicate_string_elimination</a> </p>
  
  <p>If this is correct, I have no reason to be concerned about any redundancy in JSON, as it's already been taken care of.</p>