Resolve a string like "foo[0].bla['test']"
function accessObject(obj, string) {

        var m, pos = 0;
        while ((m = string.substring(pos).match(accessExp))) {

            //         .name or       ["foo"] or [0]
            var prop = m[1] || (m[3] ? m[4] : +m[2]);
            if (obj === undefined) {
                throw new FormatError(accessObject,
                                      'Cannot access property "{}" of undefined.',
                                      prop);

            } else {
                obj = obj[prop];
            }

            pos += m[0].length;

        }

        return obj;

    }