How to access first element of JSON object array?

前端 未结 6 944
谎友^
谎友^ 2021-01-03 21:10

I exptect that mandrill_events only contains one object. How do I access its event-property?

var req = { mandrill_events: \'[{\"event\":\"inboun         


        
6条回答
  •  失恋的感觉
    2021-01-03 22:05

    '[{"event":"inbound","ts":1426249238}]' is a string, you cannot access any properties there. You will have to parse it to an object, with JSON.parse() and then handle it like a normal object

提交回复
热议问题