How can I put double quotes inside a string within an ajax JSON response from php?

前端 未结 3 1753
天涯浪人
天涯浪人 2020-12-05 04:18

I receive a JSON response in an Ajax request from the server. This way it works:

{ \"a\" : \"1\", \"b\" : \"hello \'kitty\'\" }

But I did not succeed in put

3条回答
  •  青春惊慌失措
    2020-12-05 04:45

    A little off-topic, you could use JavaScript/NodeJS on your server and use ES6 template literals (the backticks `` used around "Christian"), but 7 years later you probably already use NodeJS :)

    var myJSON = {
        "name": {
            "first": `"Christian"`,
            "last": "Broberg"
        },
        "age": 49,
        "skills": [ "JavaScript", "React", "NodeJS" ],
        "married": false,
        "superpowers": null
    }
    

提交回复
热议问题