0

Efter pushing data back and forth I have ended upp with this in a variable in javascript (browser)

"{"uri":"theDNS.com","ws":"wss://theDNS.com:8443/ws","username":"username","password":"Secret"}"

Rather then the desired "{"uri":"theDNS.com","ws":"wss://theDNS.com:8443/ws","username":"username","password":"Secret"}"

This seem to be part of the HTML4 standard, but is there some smart way to convert the chars in a string like this to "normal" chars? I currently do a replace for a number of common chars, but I figure there must be a better way.

Griffin
  • 785
  • 5
  • 13
  • 1
    Sure there's a way, but you should rather fix the code that's "*pushing data back and forth*". Somewhere in the chain it was messed up. – Bergi May 19 '22 at 21:57
  • html-entities is a package that will easily handle this for you - https://www.npmjs.com/package/html-entities - but as Bergi has said you should try to fix the cause of the problem if a html encoded json object wasn't what you were trying to achieve. – undefined May 19 '22 at 22:01
  • 1
    https://stackoverflow.com/questions/7394748/whats-the-right-way-to-decode-a-string-that-has-special-html-entities-in-it?lq=1 seem to be the best way to handle this. – Griffin May 21 '22 at 16:32

0 Answers0