javascript - Convert String containing list of JSON objects to Object Array -


a string contains list of objects serialized in json format, how convert list of json objects given in example below preferably without using jquery.

eval, stringyfy json.parse etc dont seems here.

    [         {firstname: 'laurent', lastname: 'renard', birthdate: new date('1987-05-21'), balance: 102, email: 'whatever@gmail.com'},         {firstname: 'blandine', lastname: 'faivre', birthdate: new date('1987-04-25'), balance: -2323.22, email: 'oufblandou@gmail.com'},         {firstname: 'francoise', lastname: 'frere', birthdate: new date('1955-08-27'), balance: 42343, email: 'raymondef@gmail.com'}     ]; 

update:- json string

[     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt6yaaa"},"name":"stella pavlova","phone":"(212) 842-5500","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt6yaaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt6zaaa"},"name":"lauren boyle","phone":"(212) 842-5500","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt6zaaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt70aaa"},"name":"babara levy","phone":"(503) 421-7800","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt70aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt71aaa"},"name":"josh davis","phone":"(503) 421-7800","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt71aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt72aaa"},"name":"jane grey","phone":"(520) 773-9050","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt72aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt73aaa"},"name":"arthur song","phone":"(212) 842-5500","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt73aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt74aaa"},"name":"ashley james","phone":"+44 191 4956203","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt74aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt75aaa"},"name":"tom ripley","phone":"(650) 450-8810","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt75aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt76aaa"},"name":"liz d'cruz","phone":"(650) 450-8810","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt76aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt77aaa"},"name":"edna frank","phone":"(650) 867-3450","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt77aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt78aaa"},"name":"avi green","phone":"(212) 842-5500","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt78aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt79aaa"},"name":"siddartha nedaerk","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt79aaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt7aaaq"},"name":"jake llorrac","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt7aaaq"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt6raaa"},"name":"rose gonzalez","phone":"(512) 757-6000","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt6raaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt6saaa"},"name":"sean forbes","phone":"(512) 757-6000","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt6saaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt6taaa"},"name":"jack rogers","phone":"(336) 222-7000","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt6taaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt6uaaa"},"name":"pat stumuller","phone":"(014) 427-4427","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt6uaaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt6vaaa"},"name":"andy young","phone":"(785) 241-6200","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt6vaaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt6waaa"},"name":"tim barr","phone":"(312) 596-1000","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt6waaa"},     {"attributes":{"type":"contact","url":"/services/data/v30.0/sobjects/contact/0039000000wvt6xaaa"},"name":"john bond","phone":"(312) 596-1000","createddate":"2014-05-15t06:17:48.000+0000","id":"0039000000wvt6xaaa"} ] 

i edited post make more visibly clear, maybe you'll see: value posted "json string" javascript array of objects; you're claiming you're trying convert string into. should read more on json understand how can convert , json, that's valid javascript object -- don't need it.

here's jsfiddle showing fact in action -- need set variable equal block of code you're receiving, , can access normal array/object. http://jsfiddle.net/zpxvh/

var array = /* long code */; alert(array[1]['name']; 

Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -