首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >http://schema.org如何在JSON的@上下文中使用,即使它不是JSON文件?

http://schema.org如何在JSON的@上下文中使用,即使它不是JSON文件?
EN

Webmasters Stack Exchange用户
提问于 2019-06-11 18:08:08
回答 1查看 899关注 0票数 3

就我在JSON规范中所看到的3.1节-背景而言,@context可以是:

  • 内联JSON对象:{ "@context":{ "name":"http://schema.org/name“}}
  • 或表示包含这样一个JSON对象的外部JSON文件的URI的字符串:{ "@context":"https://json-ld.org/contexts/person.jsonld“}

但是,当与schema.org词汇表一起使用时,@context总是以这样的方式使用:

代码语言:javascript
复制
{
  "@context": "http://schema.org",
}

尽管http://schema.org不是JSON文档的URI。

我错过了什么?

EN

回答 1

Webmasters Stack Exchange用户

回答已采纳

发布于 2019-06-11 20:48:32

Schema.org使用内容协商提供JSON上下文文件。

如果您在发送接受/偏爱http://schema.org的请求头时请求application/ld+json,则会发生以下情况:

  1. http://schema.org 301 -重定向到https://schema.org/ HTTP/1.1 301永久移动的内容-类型:文本/html位置:https://schema.org/
  2. https://schema.org/ 302 -重定向到https://schema.org/docs/jsonldcontext.jsonld HTTP/1.1 302找到的内容-类型: text/html;charset=utf-8位置:https://schema.org/docs/jsonldcontext.jsonld
  3. https://schema.org/docs/jsonldcontext.jsonld获得HTTP/1.1200OK内容类型: application/ld+json;charset=utf-8

您可以使用卷曲自己测试它:

代码语言:javascript
复制
curl -L -H "Accept: application/ld+json" http://schema.org

-L使卷曲跟随重定向

-H在请求中包含以下标题(Accept: application/ld+json)

票数 2
EN
页面原文内容由Webmasters Stack Exchange提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://webmasters.stackexchange.com/questions/123409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档