javascript - Decode html in json -


i have html in json has been encoded (by c#) :

{"itemid":6,"glossaryword":"ante","glossarydescription":"\u003cp\u003e\r\n\t\u003cstrong\u003eup ante\u0026nbsp;\u003c/strong\u003e\u003c/p\u003e\r\n\u003cul\u003e\r\n\t\u003cli\u003e\r\n\t\t\u003cstrong\u003ehere\u003c/strong\u003e\u003c/li\u003e\r\n\t\u003cli\u003e\r\n\t\t\u003cstrong\u003eis\u0026nbsp;\u003c/strong\u003e\u003c/li\u003e\r\n\t\u003cli\u003e\r\n\t\t\u003cb\u003esomething\u003c/b\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n","categoryid":6} 

but how decode glossarydescription in javascript/angularjs displays html tags <p> & <strong> etc? :)

you don't need anything. string "\u003cp\u003e" (for example) isn't encoded in way needs decoding—it's equivalent "<p>". if type "\u003cp\u003e" == "<p>" in console you'll see return true. since "encoded" string same non-"encoded" string, can use them same way. take look:

var obj = {"itemid":6,"glossaryword":"ante","glossarydescription":"\u003cp\u003e\r\n\t\u003cstrong\u003eup ante\u0026nbsp;\u003c/strong\u003e\u003c/p\u003e\r\n\u003cul\u003e\r\n\t\u003cli\u003e\r\n\t\t\u003cstrong\u003ehere\u003c/strong\u003e\u003c/li\u003e\r\n\t\u003cli\u003e\r\n\t\t\u003cstrong\u003eis\u0026nbsp;\u003c/strong\u003e\u003c/li\u003e\r\n\t\u003cli\u003e\r\n\t\t\u003cb\u003esomething\u003c/b\u003e\u003c/li\u003e\r\n\u003c/ul\u003e\r\n","categoryid":6};    document.write(obj.glossarydescription);


Comments

Popular posts from this blog

toolbar - How to add link to user registration inside toobar in admin joomla 3 custom component -

linux - disk space limitation when creating war file -