Using a for loop with JSON object/array elements?
<p>I'm trying to create a <code>for()</code> loop with JSON data that's already been decoded, the problem is adding my loop variable (in this case <code>i</code>), to the end of the element that I'm referencing.</p>

<p><strong>For example, my JSON structure, dumped:</strong></p>

<pre><code>{
    "url": "http://www.example.com",
    "rid": 1,
    "rname": "Apple iPhone 4 Rotation",
    "rmin": 90,
    "rmax": 150,
    "blank": 0,
    "geo_country_0": "GB",
    "geo_url_0": "http://en",
    "geo_country_1": "FR",
    "geo_url_1": "http://fr",
    "geo_country_2": "ES",
    "geo_url_2": "http://es"
}
</code></pre>

<p>In the case of <code>geo_country_</code> and and <code>geo_url_</code> I need to append a number, in this case the loop variable.</p>

<p><strong>My actual for loop, for a better understanding:</strong></p>

<pre><code>for(i = 1; i &lt; count; i++) {
                $('#geo-location').append('&lt;div id="glt_' + i + '" class="clone"&gt;&lt;select name="g_country['+i+']" class="glt-input-c"&gt;' + options + '&lt;/select&gt;&lt;input type="text" name="g_url[' + i + ']" class="glt-input-c" value="' + data.geo_url_i+ '"/&gt;&lt;/div&gt;');
                $('select[name="g_country['+i+']"').find('option[value="' + data.geo_country_i+ '"]').attr('selected','selected');
            }
</code></pre>

<p>So far I've tried:</p>

<ul>
<li>Encasing the the <code>i</code> like <code>[i]</code>.</li>
<li>Escaping it like <code>\i</code>. (This was probably a stupid idea).</li>
<li>Adding a pre-fixing <code>+</code> like, <code>+ data.geo_country + i +</code>.</li>
</ul>

<p>What do I need to do to have <code>i</code> interpreted properly?</p>

<p>Any help would be greatly appreciated!</p>
