如何解析其中包含HTML内容的JSON请求

时间:2019-07-17 14:28:50

标签: html json parsing escaping

我有两个不同的要求。我试图将其中包含HTML内容的JSON请求转换为XML,但我只需要访问JSON请求中存在的HTML内容。请提出前进的方向。

我尝试使用JSON解析器/读取,它根本无法工作。另外,请提出如何对JSON中HTML内容的序列进行转义的建议。

{
    "Message": {
        "id": "1234567889",
        "type": "mailbox",
        "header": "ABCD",
        "Systemproperty": [
            {
                "name": "Subject",
                "value": "test mail"
            },
            {
                "name": "Body",
                "value": "<html><!-- Text between angle brackets is an HTML tag and is not displayed.Most tags, such as the HTML and /HTML tags that surround the contents ofa page, come in pairs; some tags, like HR, for a horizontal rule, stand alone. Comments, such as the text you're reading, are not displayed whenthe Web page is shown. The information between the HEAD and /HEAD tags is not displayed. The information between the BODY and /BODY tags is displayed.--><head><title>Enter a title, displayed at the top of the window.</title></head><!-- The information between the BODY and /BODY tags is displayed.--><body><h1>Enter the main heading, usually the same as the title.</h1><p>Be <b>bold</b> in stating your key points. Put them in a list: </p><ul><li>The first item in your list</li><li>The second item; <i>italicize</i> key words</li></ul><p>Improve your image by including an image. </p><p><img src="http://www.mygifs.com/CoverImage.gif" alt="A Great HTML Resource"></p><p>Add a link to your favorite <a href="https://www.dummies.com/">Web site</a>.Break up your page with a horizontal rule or two. </p><hr><p>Finally, link to <a href="page2.html">another page</a> in your own Web site.</p><!-- And add a copyright notice.--><p>&#169; Wiley Publishing, 2011</p></body></html>"
            }
        ],
        "sender": {
            "mail": "blabla@bla.ie"
        },
        "receiver": {
            "type": "EMAIL",
            "mail": "blabla@bla.com",
            "id": "1234567891234567"
        }
    }
}
  

线程“主线程”中的异常com.jayway.jsonpath.InvalidJsonException:net.minidev.json.parser.ParseException:意外令牌-位于位置193。       在com.jayway.jsonpath.spi.json.JsonSmartJsonProvider.parse(JsonSmartJsonProvider.java:64)       在com.jayway.jsonpath.internal.ParseContextImpl.parse(ParseContextImpl.java:37)       在com.jayway.jsonpath.JsonPath.parse(JsonPath.java:599)       在three.ie.thbs.com.JsonPathFinder.main(JsonPathFinder.java:20)   由以下原因引起:net.minidev.json.parser.ParseException:意外令牌-位于位置193。       在net.minidev.json.parser.JSONParserBase.readObject(JSONParserBase.java:567)

0 个答案:

没有答案