2

I would like to know how to convert the string below to an object in Javascript:

var string = '{"id":"50","actor":"1","subject":"1","object":"18","message":"a ajout\u00e9","status":"unseen"}'

In fact, I would like that after converting the string above to an object, I will be able to access to any element of that object. For example, if I convert the string to an object called "obj" I will be able to access to the value of the element "id" (which is "50") in such way: obj.id

Thanks in advance.

Nadim
  • 382
  • 1
  • 7
  • 29
  • The linked question used for closing is totally obsolete. If you're not happy with my answer below use this one : http://stackoverflow.com/questions/6487167/deserialize-from-json-to-javascript-object – Denys Séguret May 29 '14 at 16:04

1 Answers1

4

This string is in JSON.

Use

var obj = JSON.parse(string);
Denys Séguret
  • 372,613
  • 87
  • 782
  • 758