Struggling with a JavaScript and JSON issue.
There's a function that includes a JSON object:
blah=function(i){
var hash= ({
"foo" : "bar",
"eggs":"bacon",
"sausage":"maple syrup"
});
var j=eval(hash); // Convert to Object
console.log(j.toSource()); // Only in firefox!
console.log(j.i); // Trying to get the value of 'i' like foo - which should be bar
}
Call the function with blah('foo');
in an attempt to console log "bar" from the JSON object.
The problem: all I get is "undefined" because the function is treating "i" as a string.
How can "i" be typecast to access the JSON object?
Need help -- headache inducing, Google search failed!
Thanks,
Alex