I'm trying to access to nested properties of an object from a string.
Here is my sample code :
var obj = {
  'text': 'hello',
  'foo': {
    'float': 0.5,
    'bar': {
      'id': 42
    }
  }
};
var keyOne = 'text';
var keyTwo = 'foo.float';
var keyThree = 'foo.bar.id';
console.log(obj[keyOne]); // successfully log 'hello'
console.log(obj[keyTwo]); // trying to log '0.5'
console.log(obj[keyThree]); // trying to log '42'
I'm trying to do it in JS but I also have jQuery ready for a cleaner solution.
 
     
    