weixin_33674437 2015-10-06 09:20 采纳率: 0%
浏览 58

发送带有异常密钥的JSON

I've object in js with keys-selectors:

{
    "[data-index="0"]": {
       // something
    },
    "> .class > .one": {
       key: "very bad+ \"\' string"
    }
 }

How send this object via ajax without any changes in the keys and with correct values?

By correct values I mean that "very bad+ \"\' string" should be total escaped, but save all chars and signs to store in Database.

PS. I know that i can send objects via AJAX

  • 写回答

2条回答 默认 最新

  • weixin_33691700 2015-10-06 09:22
    关注

    JSON.stringify will transform your object into a JSON string. It can handle special characeters, don't worry.

    var json = JSON.stringify(myObject);
    
    评论

报告相同问题?