[{
"value": 71,
"label": "123 Foobar \'eha-Kauai, Hawaii, United States"
},
{
"value": 75,
"label": "456 Foobar \'elima-Kauai, Hawaii, United States"
}]
但这有效:
var foo = [{
"value": 71,
"label": "123 Foobar \'eha-Kauai, Hawaii, United States"
},
{
"value": 75,
"label": "456 Foobar \'elima-Kauai, Hawaii, United States"
}];
console.log(foo.length); // returns 2
注意:字符串由函数生成,可以通过以下方式使用:
<script>
var foo = '<%= vbs_JSONEncode("Hello World") %>'; // being inconsistent
var bar = "<%= vbs_JSONEncode(str_Hello_Msg) %>"; // with the quotes
</script>
或者干脆:
Response.ContentType = "application/json"
Response.Write vbs_JSONEncode("Hello World")
解决方法:
你不需要用反斜杠来逃避’.逃避“.