I exptect that mandrill_events only contains one object. How do I access its event-property?
var req = { mandrill_events: '[{"event":"inbound","ts":1426249238}]' }
var req = { mandrill_events: '[{"event":"inbound","ts":1426249238}]' }
console.log(Object.keys(req)[0]);
Make any Object array (req), then simply do Object.keys(req)[0] to pick the first key in the Object array.
Object.keys(req)[0] will return you the id of the object in that array, so to get the actual value you need: mandrill_events[Object.keys(req)[0]].eventevent and ts?To answer your titular question, you use [0] to access the first element, but as it stands mandrill_events contains a string not an array, so mandrill_events[0] will just get you the first character, '['.
So either correct your source to:
var req = { mandrill_events: [{"event":"inbound","ts":1426249238}] };
and then req.mandrill_events[0], or if you're stuck with it being a string, parse the JSON the string contains:
var req = { mandrill_events: '[{"event":"inbound","ts":1426249238}]' };
var mandrill_events = JSON.parse(req.mandrill_events);
var result = mandrill_events[0];
[ is returned as content if the variable is string, not object
JSON.parse(str).JSON.parse(req[mandrill_events])[0].eventwill return"inbound".JSON.parse(req.mandrill_events)[0]["event"]would