JSON String inside a JSON

前端 未结 3 849
忘了有多久
忘了有多久 2021-01-01 17:04

I want to create a JSON string inside a JSON request. Here is my code,

Fiddle

JS

var x = {
    a: 1,
    b: \'a sample text\         


        
3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-01 17:32

    There is no problem. It's just your console.log that shows all strings by simply delimiting with ".

    As you say this request object is used in a JSON request, where it will be JSON.stringifyed another time, with the valid result

    {"t":"{\"a\":1,\"b\":\"a sample text\"}","c":2,"r":"some text"}
    

提交回复
热议问题