Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON parse string having Apostrophe (Single Quote)

Tags:

javascript

How do i parse the following string

var a = JSON.parse('[' + '{"NoteName":"it's my life","UserId":"100","NoteActive":true,"UserEmail":"[email protected]","CreatedDate":"8/13/2012 1:47:35 PM"}' + ']');
like image 899
Muzafar Khan Avatar asked Oct 08 '15 10:10

Muzafar Khan


2 Answers

You have just to escape a single quote it\'s

var a = JSON.parse('[' + '{"NoteName":"it\'s my life","UserId":"100","NoteActive":true,"UserEmail":"[email protected]","CreatedDate":"8/13/2012 1:47:35 PM"}' + ']');
console.log(a);
like image 167
alessandro Avatar answered Oct 05 '22 04:10

alessandro


Replace it's with it\'s

'[' + '{"NoteName":"it\'s my life","UserId":"100","NoteActive":true,"UserEmail":"[email protected]","CreatedDate":"8/13/2012 1:47:35 PM"}' + ']'
like image 24
Muhammad Usman Avatar answered Oct 05 '22 06:10

Muhammad Usman