JSON String inside a JSON

前端 未结 3 850
忘了有多久
忘了有多久 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条回答
  •  萌比男神i
    2021-01-01 17:37

    That's just the way the browser console shows you the value of a string, by wrapping in double quotes for the output. This is perfectly normal and nothing is broken.

    You can test it by transforming your JSON string back to an object and using a property.

    console.log( JSON.parse(request.t).b ); // a sample text
    

提交回复
热议问题