How might I escape Unicode characters in a JSON string using JavaScript?

Posted by user293006 on Stack Overflow See other posts from Stack Overflow or by user293006
Published on 2010-03-13T15:52:29Z Indexed on 2010/03/13 16:05 UTC
Read the original article Hit count: 162

JSON String:

{
  "id":31896,

  "name":"Zickey attitude - McKinley,
   La Rosi\u00e8re,
   21 ao\u00fbt 2006",
...

}

this causes an unterminated string in JavaScript.

My attempt at a solution is:

data.replace(/(\S)\1(\1)+/g, '');

or

data.replace(/\\u([0-9A-Z])/, '');

any ideas/solution?

Example: http://api.jamendo.com/get2/id+name+url+stream+album_name+album_url+album_id+artist_id+artist_name/track/jsonpretty/track_album+album_artist/?n=13&order=ratingmonth_desc&tag_idstr=jazz

last node is the problem, fyi.

(/\\u([0-9A-Z])/, '\1');

© Stack Overflow or respective owner

Related posts about string-manipulation

Related posts about JavaScript