Mohamed Naguib
Mohamed Naguib

Reputation: 1730

Parsing an array containing a single object in Node JS

I have an object like that

[{"created_at":"Thu Aug 15 11:45:05 +0000 2013","id":367975226434670592,"id_str":"367975226434670592","text":"What makes @asana the 'Tesla of productivity tools': http:\/\/t.co\/TFzHFEpXqJ"}]

And I am interested only in 'text' part in this object.

I tried

var obj = JSON.parse(data);
console.log( obj.text );

but It didn't work, help ?

Upvotes: 1

Views: 1156

Answers (1)

Drew R
Drew R

Reputation: 3088

You are parsing an array containing your object as its only element. Try obj[0].text.

Upvotes: 4

Related Questions