CodingCan't get value from key when obj is imported

 

Press Ctrl+Enter to quickly submit your post
Quick Reply  
 
 
  
 From:  CHYRON (DSMITHHFX)   
 To:  ALL
41790.5 
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"}
A simple trick makes it terrifyingly easy to see whether or not someone has muted you on Twitter
0/0
 Reply   Quote More 

 From:  CHYRON (DSMITHHFX)   
 To:  ALL
41790.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

A simple trick makes it terrifyingly easy to see whether or not someone has muted you on Twitter
0/0
 Reply   Quote More 

Reply to All    
 

1–6

Rate my interest:

Adjust text size : Smaller 10 Larger

Beehive Forum 1.5.2 |  FAQ |  Docs |  Support |  Donate! ©2002 - 2024 Project Beehive Forum

Forum Stats