remove double quotes from Json return data using Jquery

前端 未结 8 2115
半阙折子戏
半阙折子戏 2020-12-08 06:29

I use JQuery to get Json data, but the data it display has double quotes. It there a function to remove it?

$(\'div#ListingData\').text(JSON.stringify(data.         


        
8条回答
  •  醉酒成梦
    2020-12-08 07:20

    Someone here suggested using eval() to remove the quotes from a string. Don't do that, that's just begging for code injection.

    Another way to do this that I don't see listed here is using:

    let message = JSON.stringify(your_json_here); // "Hello World"
    console.log(JSON.parse(message))              // Hello World
    

提交回复
热议问题