json值内的单引号 [英] Single quotes within json value
本文介绍了json值内的单引号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Javascript无法读取此json字符串,因为它包含一个单引号字符,并且将其视为字符串的结尾.
Javascript fails to read this json string as it contains a single quote character which it sees as the end of the string.
我该如何转义单引号,使它不被视为字符串的结尾?
How can I escape the single quote so that it is not seen as the end of the string?
var json = '{"1440167924916":{"id":1440167924916,"type":"text","content":"It's a test!"}}';
var parsed = JSON.parse(json);
推荐答案
使用反斜杠
这篇关于json值内的单引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文