admin管理员组文章数量:1326474
I have a json object such as:
var json = {
"title": "Math Symbols: ¬",
"sections": [
"The ¬ symbol",
"¬ and y"
]
};
I need to replace all instances of the "¬" character with something that looks like the Mathematical symbol for x: sample.
Side note: I can't use that actual symbol (html entity 𝑥
) because the Arial font i'm using doesn't support it. So I was planning on replacing "¬" with <span class="math">x</span>
and styling the math class with Times New Roman & italic.
I can't change the Arial Font, and I don't need any other Math symbols - MathML support or the like isn't necessary.
Something like this would be ideal:
json = json.replace("¬", "<span class='math'>x</span>");
I have a json object such as:
var json = {
"title": "Math Symbols: ¬",
"sections": [
"The ¬ symbol",
"¬ and y"
]
};
I need to replace all instances of the "¬" character with something that looks like the Mathematical symbol for x: sample.
Side note: I can't use that actual symbol (html entity 𝑥
) because the Arial font i'm using doesn't support it. So I was planning on replacing "¬" with <span class="math">x</span>
and styling the math class with Times New Roman & italic.
I can't change the Arial Font, and I don't need any other Math symbols - MathML support or the like isn't necessary.
Something like this would be ideal:
json = json.replace("¬", "<span class='math'>x</span>");
Share
Improve this question
asked Aug 19, 2013 at 10:24
aaronjbaptisteaaronjbaptiste
5544 silver badges14 bronze badges
1 Answer
Reset to default 11This converts the JSON into string
JSON.stringify(json).replace(/¬/g, "<span class='math'>x</span>")
and then you could convert it back to JSON
JSON.parse(json)
本文标签: javascriptString replace values recursively in jsonStack Overflow
版权声明:本文标题:javascript - String replace values recursively in json - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742208803a2433319.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论