Javascript Object Property Undefined (GM_getValue(), GM_listValues(), Greasemonkey, Tampermonkey)
<p>this is probably something simple, I dunno, but I am trying to create a string from an object returned by Tampermonkey (basically Greasemonkey for Chrome) <code>GM_getValue()</code> function.</p>

<p>The final code looks like this...</p>

<pre><code>//Call GM_listValues() to get keys of all stored values
var keys = GM_listValues();

//Code to create CSV string out of first 10 records
var csvString = '';
for (j=0; j&lt;10; ++j) {
    var temp = GM_getValue(keys[j]);

    csvString = csvString + '"' + temp.id + '"' + ",";
    csvString = csvString + '"' + temp.time + '"' + ",";
    csvString = csvString + '"' + temp.outcome + '"' + ",";
    csvString = csvString + '"' + temp.condition + '"' + ",";
    csvString = csvString + '"' + temp.wager + '"' + ",";
    csvString = csvString + '"' + temp.chance + '"' + ",";
    csvString = csvString + '"' + temp.profit + '"' + ",";
    csvString = csvString + '\n';
}

//Code to download CSV
var a         = document.createElement('a');
a.href        = 'data:attachment/csv,' +  encodeURIComponent(csvString);
a.target      = '_blank';
a.download    = 'myFile.csv';

document.body.appendChild(a);
a.click();
</code></pre>

<p>However, the result is a bunch of undefined fields.  When I debug, I see that the variable <code>keys</code> is getting populated correctly with the keys.   I see that the variable <code>temp</code> is getting the correct data as well.  When I do <code>typeof temp</code> it says <code>object</code> so I assume it's an object.  </p>

<p>When I <code>console.log(temp)</code> it says <code>json_val: {"id":"2132867232","time":"07:52","outcome":"84","condition":"&gt;1","wager":"0.50000m฿","chance":"98 %","profit":"+0.00520"}</code></p>

<p>Does the <code>json_val:</code> have something to do with why doing <code>console.log(temp.id)</code> returns <code>undefined</code>?</p>

<p>I also tried <code>temp["id"]</code> and get undefined as well.</p>

<p>Any help is much appreciated.  Thanks in advance.</p>