javascript - JSON.parse unexpected character with special characters in string? -


i having trouble using json.parse on characters. i'm receiving data via api, don't have means force form of encoding on server side, data provided me as-is.

this json in question:

{"name": "»»»»»»»"} 

i created jsfiddle json data , basic json.parse function returns "unexpected token in json @ position 11". (there special characters in there won't see in browser, jsfiddle show them)

https://jsfiddle.net/4u1ltvlm/2/

how go fixing string prior doing json.parse on it, without losing special characters?

edit: modified jsfiddle , json contain string causing trouble, it's less confusing everyone.

json.parse needs string consists of unicode characters (see json parsing unicode characters).

for json.parse method fails, because string contains non-unicode characters. if paste string http://jsonparseronline.com/ see fails because of character, character browser displays if string not correctly encoded.

so, if don't have way change endcoding of string, won't able this. can try this change encoding, ti give definite answer need know how string encoded in first place


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -