You need to double-encode the \ characters in String before \\ .
var s = '{"page_name":"Test page","page_title":"Test title","site":"0","page_url":"http://saulius.epickitdev.com/test-page","page_type":"1","bg_type":"gradient","background_img_url":"","fill_bg_color":"","background_color":"","background_gradient_top":"5194c4","background_gradient_bottom":"000000","video_type":"yt","youtube_video_url":"","youtube_video_start_from":"","mp4_video_url":"","webm_video_url":"","ogg_video_url":"","width_type":"fixed","width_padding":"10","layout_color":"cc25cc","border_size":"3","border_color":"5a7de6","container_position":"middle","container_position_left":"","container_position_right":"","meta_title":"mtest","meta_description":"mdesc","meta_keyword":"mkey","fb_title":"ftitle","fb_description":"fdesc","header_script":{"1":"<meta name=\\"keywords\\" content=\\"h1\\">","2":"<meta name=\\"keywords\\" content=\\"h2\\">"},"footer_script":[""],"redirect_url":"","exit_message":""}' $.parseJSON(s)
This is because they exit the line inside the line.
The top-level string is an integer value, so deploying one level of escaping leads to this,
{"1":"<meta name="keywords" content="h1">"}
This is not true because the quotation marks in the value are no longer escaped since the top-level JavaScript string expands them. When this string literal is read by the JavaScript interpreter, all the characters \ expand to the same level, which means that \" becomes simple. " Then you need to process the JSON string, but it is no longer valid, since the quotation marks that you wanted to avoid are now not protected (in fact, they never disappeared, they just seemed like that). When you use single quotes, you donโt need to escape, " but you can always avoid anything if itโs not a special character, it just doesnโt do anything.
So, in order for the quotes to be escaped after processing the top-level string, you need to exit \ itself.
var s = '{"1":"<meta name=\\"keywords\\" content=\\"h1\\">"}' console.log(s) //'{"1":"<meta name=\"keywords\" content=\"h1\">"}' $.parseJSON(s)