获取在HTML源代码中为JSON键和值而转义的引号

huangapple 未分类评论38阅读模式
英文:

Getting escaped quotes in HTML source code for JSON key and value

问题

我在HTML源代码中使用Java对序列化JSON遇到了问题。
我对JSON进行了序列化,因为我需要在HTML源代码中使用它,但不知何故,JSON键的引号,例如"key":"value"在查看HTML源代码时显示为已转义,例如:

[{"title":"test-title"}]变为[{"title":"test-title"}]

因此,"被转义为"。现在,一旦DOM被呈现并且JavaScript开始运行,情况就会变好。但我需要在源HTML代码中使用正确的结构,其中包含",而不是"。有人知道如何处理这个问题吗?或者是否有可能做到这一点?如果需要,我可以提供更多详细信息。

英文:

I have a problem regarding serialized JSON via Java on HTML source code.
I serialized the json as I need to have it in the HTML source code, but somehow the quotes for the JSON key like "key":"value" are showing as escaped when I view html source code.example :

[{"title":"test-title"}] becomes [{"title":"test-title"}]

So the " is getting escaped to " Now, as soon as the DOM is rendered and javascript kicks in this becomes fine. But i need the correct structure with " instead of " in the source HTML code. Does anyone know how to deal with this? or if it's even possible to do this? I am happy to provide with more details if required.

huangapple
  • 本文由 发表于 2020年4月8日 00:23:47
  • 转载请务必保留本文链接:https://java.coder-hub.com/61084712.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定