Can't get value from key when obj is imported

From: CHYRON (DSMITHHFX)11 Aug 2016 21:31
To: ALL1 of 6
I'm messing around object key value stuffs and hit a wall:

If I define an object's key:value pairs in the script and then get the value of a certain key, it works fine.

If I $.get  an external txt file then it returns "undefined" for the value. If I iterate through the same imported file using $.each, it'll faithfully list each key:value pair.
Code: 
$(document).ready(function() {    
    
// DATE    
    var now = new Date(Date.now());
    var mond = function() {
        return ('0' + (now.getMonth() + 1)).slice(-2);
    }
    var dayd = function() {
        return ('0' + now.getDate()).slice(-2);
    }
    var dayKey = mond() + dayd();
    $.get('alldatestest.txt', function(data) {
        var picsObj = {data};
        alert(picsObj.dayKey);
        /*$.each(picsObj, function(key,value) {
            //alert(key + ':' + value);
            if ( key = dayKey ) {
                //alert('yes');
                alert(value);
            }
        });*/
    });
});    

Here's the external file as reference above:
Code: 
0810: '',
0811: '100315/5065359-R1-19-20_scaled.jpg',
1004: '100315/5065359-R1-19-20_scaled.jpg',
1008: 'images/CNV00016-interim.jpg'
From: Peter (BOUGHTONP)11 Aug 2016 23:21
To: CHYRON (DSMITHHFX) 2 of 6
var picsObj = JSON.parse('{'+data+'}');
From: CHYRON (DSMITHHFX)12 Aug 2016 02:07
To: Peter (BOUGHTONP) 3 of 6
Thanks, I'll try it in the am.
From: koswix12 Aug 2016 13:19
To: CHYRON (DSMITHHFX) 4 of 6
Did it work?
From: CHYRON (DSMITHHFX)12 Aug 2016 13:48
To: ALL5 of 6
Seems to be working now. I had to stick the brackets in the external file & also change its single quotes to double, and switch .dayKey to [dayKey] in the script:
Code: 

    $.get('alldatestest.txt', function(data) {
        var picsObj = JSON.parse(data);
        alert(dayKey + ' ' + picsObj[dayKey]);
    });
- returns "0812 100315/5065359-R1-19-20_scaled.jpg"

This was also helpful: http://json.parser.online.fr/

Thanks Peter!

Edit: to clarify, here's the new "alldatestest.txt" -- I also had to wrap keys in quotes per above online parser:
 
Code: 
{"0810":"images/CNV00016-interim.jpg",
"0812": "100315/5065359-R1-19-20_scaled.jpg",
"1004": "100315/5065359-R1-19-20_scaled.jpg",
"1008": "images/CNV00016-interim.jpg"}
EDITED: 12 Aug 2016 14:18 by DSMITHHFX
From: CHYRON (DSMITHHFX)19 Aug 2016 17:07
To: ALL6 of 6
And now you can browse back and forth through the Daily Bad Pictures*, thanks to stack overflow and their diabolical spell
 
Code: 
Object.keys(obj).indexOf(key)


(you're not supposed to be able to do indexy stuffs on objects, but there you have it  (angel) )

http://www.designartcraft.com/photo/afbp.htm

*subject to buggery (NJ), breakage and general fail

EDITED: 19 Aug 2016 17:09 by DSMITHHFX