文本可以用 URIComponent 编码而不是转义吗?

Can text be encoded with URIComponent instead of escaped?

示例:

转义的文本(在 articleBody 中):

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "NewsArticle",
  "headline": "Article headline",
  "alternativeHeadline": "The headline of the Article",
  "image": ["thumbnail1.jpg", "thumbnail2.jpg"],
  "datePublished": "2015-02-05T08:00:00+08:00",
  "description": "A most wonderful article",
  "articleBody": "\"Hello!\" said Bob.\n\"Hi,\" said Jane, \"Go away.\""
}
</script>

以及使用 URIComponent 编码的相同文本(同样在 articleBody 中):

    <script type="application/ld+json">
    {
      "@context": "http://schema.org",
      "@type": "NewsArticle",
      "headline": "Article headline",
      "alternativeHeadline": "The headline of the Article",
      "image": ["thumbnail1.jpg", "thumbnail2.jpg"],
      "datePublished": "2015-02-05T08:00:00+08:00",
      "description": "A most wonderful article",
      "articleBody": "%22Hello!%22%20said%20Bob.%0A%22Hi%2C%22%20said%20Jane%2C%20%22Go%20away.%22%0A"
    }
    </script>

你不能。 Google 不会解析编码文本,这将导致编码字符出现在丰富的 snippet/rich 卡片中。

这是一个非常基本的示例 — 复制下面的代码并将其粘贴到 Google's schema checker:

<script type="application/ld+json">
{
  "@context": "http://schema.org/",
  "@type": "Recipe",
  "name": "Perfect%20Apple%20Pie",
  "image": "http://images.edge-generalmills.com/56459281-6fe6-4d9d-984f-385c9488d824.jpg"
}
</script>

单击 'Validate',您将看到一个绿色的 'Preview' 按钮。单击预览时,您将看到以下内容: