如何使用schema.org定义手机类型(家庭,办公室,工作)?

Ced*_*ont 1 schema.org json-ld

如何使用Schema.org定义电话类型?

例如,我想在Json-ld中有这个:

    "phones" : [
    {
        "type" : "office",
        "number" : "123456789"
    },
    {
        "type" : "work",
        "number" : "123456789"
    }
    ]
Run Code Online (Sandbox Code Playgroud)

有没有办法使用schema.org作为上下文来定义这些?我查看了FOAF或goodRelations,但他们都只使用一部电话:http://schema.org/telephone

Mar*_*ler 5

您需要使用contactPoint而不是telephone属性.所以,你的JSON-LD文档看起来像这样:

"contactPoint" : [
  {
    "contactType" : "office",
    "telephone" : "123456789"
  },
  {
    "contactType" : "work",
    "telephone" : "123456789"
  }
]
Run Code Online (Sandbox Code Playgroud)

请注意,您可以更改JSON-LD上下文以获得所需形状的JSON.例如:

{
  "@context": [
    "http://schema.org",
    {
      "phones": "http://schema.org/contactPoint",
      "type": "http://schema.org/contactType",
      "number": "http://schema.org/telephone"
    }
  ],
  "phones" : [
    {
      "type" : "office",
      "number" : "123456789"
    },
    {
      "type" : "work",
      "number" : "123456789"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)