标签: json-ld

以 JSON-LD 表示法同时使用一种以上类型

格式约定在 JSON-LD 表示法中使用不止一种类型是否有效?像这儿:

{
 "@context":    "http://schema.org",
 "@type":
     [
     "MusicalEvent",
     "CreativeWork"
     ],
 "name": "Name",
 "url": "http://example.com"
}
Run Code Online (Sandbox Code Playgroud)

谢谢!

structured-data microdata linked-data json-ld

1
推荐指数
1
解决办法
239
查看次数

如何实现JSON-LD?

我今天一直在阅读关于JSON-LD的内容,我了解它的用途,格式,并且我可以把它放在脚本标签中; 但是,我不明白以下几点:

  1. 除了网站的脚本标记之外,这些数据可以放在哪里?当我查看说他们使用JSON-LD的网站的页面来源时,我一直期望在脚本标签或包含的.json文件中找到JSON-LD内容,但由于我没有看到任何这些,它引导我相信它必须可以在不同的位置访问.

  2. 这些信息集通常是如何为大型网站构建的?

  3. 其他站点如何找到要使用该信息的JSON-LD文件,对象或数据?

在野外看到一个例子真的很棒.

html json-ld

1
推荐指数
1
解决办法
969
查看次数

如何在.Net中将json转换为json-ld

我正在尝试将 json 转换为 json-ld。到目前为止,我已经尝试过来自 nuget 的 json-ld.net 库(它是 nuget3 的一部分):https ://www.nuget.org/packages/json-ld.net/

var jtoken = JsonLD.Util.JSONUtils.FromString(response);
var options = new JsonLdOptions();
options.SetBase("http://json-ld.org/test-suite/tests/");
options.SetProduceGeneralizedRdf(true);
var context = JsonLD.Util.JSONUtils.FromString(Properties.Resources.jasonldcontext);
options.SetExpandContext((JObject)context);
var jtokenout = JsonLdProcessor.Compact(jtoken, context, options);
var sz = JSONUtils.ToString(jtokenout);
Run Code Online (Sandbox Code Playgroud)

上下文资源:

{"@context": {
"ex": "http://example.org/",
"term1": {"@id": "ex:term1", "@type": "ex:datatype"},
"term2": {"@id": "ex:term2", "@type": "@id"}
}}
Run Code Online (Sandbox Code Playgroud)

我的 json 存在且有效。它来自 REST 服务。(响应),并填充 jtoken。但是, sz 仅包含上下文:

context":{"ex":"http://example.org/","term1":
{"@id":"ex:term1","@type":"ex:datatype"},"term2":
{"@id":"ex:term2","@type":"@id"}}}
Run Code Online (Sandbox Code Playgroud)

c# json-ld

1
推荐指数
1
解决办法
4114
查看次数

google-rich-snippets json-ld中使用的完整数据类型列表(@type)

有没有在谷歌的丰富网页摘要@type的任何完整列表json-ld,有很多数据类型,其用途Organisation,listItem,Recipe,等

types json-ld google-rich-snippets

1
推荐指数
1
解决办法
1405
查看次数

如何在JSON-LD中编写循环RDF图?

我的图表如下:

  [Natasha]--- knows--> [Bob]
  [Bob]--- brother of--> [Alice]
  [Alice]--- play with--> [Natasha]
Run Code Online (Sandbox Code Playgroud)

如何将其嵌入JSON-LD?

我当前的解决方案不起作用:

{
"@context" : {
   "Natasha" : "http://names.example.org/resource/name/Natasha",
   "Bob" : "http://names.example.org/resource/name/Bob",
   "Alice" : "http://names.example.org/resource/name/Alice",
   "knows" : "http://example.com/knows",
   "brother-of" : "http://example.com/brother-of",
   "play-with" : "http://example.com/play-with"
},
 "@id" : "Natasha", 
  "knows" : 
        {  "@id" : "Bob", 
           "brother-of" : { 
                    "@id" : "Alice",
              "play-with" : "Natasha"
        }

        }
    }
Run Code Online (Sandbox Code Playgroud)

rdf json-ld

1
推荐指数
1
解决办法
58
查看次数

单个页面上有多个 FAQPage 精选片段

我们希望使用 JSON-LD 格式以FAQPage的形式添加特色片段。使用 Google 页面概述上的“查看标记”链接FAQPage,我们可以获得下面的示例特色片段。这似乎意味着该页面的所有问题都应该在一个<script>标签中。

我们通过Google 的结构化数据测试工具丰富结果工具运行了以下内容,它返回了零错误。然而,没有提到它全部在一个script标签中。

问题

如果我们要使用FAQPage特色片段,我们需要使用的正确变体是什么(1 或 2)?

我们尝试了什么

变体 1 - 将所有问题集中在一个script标签中:

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "FAQPage",
  "mainEntity": [{
    "@type": "Question",
    "name": "What is the return policy?",
    "acceptedAnswer": {
      "@type": "Answer",
      "text": "Most unopened items in new condition and returned within <strong>90 days</strong> will receive a refund or exchange. Some items have a modified return policy noted on the receipt …
Run Code Online (Sandbox Code Playgroud)

html schema.org json-ld google-rich-snippets

1
推荐指数
1
解决办法
1514
查看次数

从JSON转换为JSON-LD

我正在开展一个项目,要求我们使用现有的服务,这个服务会说json-ld.我们说json.我仍在通过http://www.w3.org/TR/json-ld/文档以及如何转换json> json-ld(和返回).

一些问题..如果我提供2个这样的上下文..

"@context": [
        "http://example/test1/core.jsonld",
        "http://example2/test2/core.jsonld"
    ],
Run Code Online (Sandbox Code Playgroud)

密钥如何知道要应用哪个前缀?例如

(test1 or test2)name : ..
(test1 or test2)date : ..
(test1 or test2)address : ..
Run Code Online (Sandbox Code Playgroud)

到目前为止,我对其工作原理的理解是,任何json都可以转换为json ld.我们需要为它提供一个上下文,因此它知道'iri'或命名空间.

另外,我正在使用的当前示例json-ld也有一些没有定义前缀的键,所以我想有一个默认值,但没有任何东西可以告诉我默认是什么(没有@vocab,字面上只是两个上下文定义).我想默认是一个上下文,但在这种情况下,我有2.

如果我错了,请纠正我,但所有json都可以转换为json-ld,反之亦然?我正在寻找Java解决方案ATM.

我想要的一个非常基本的例子

{
    "id": 1,
    "name": "A green door",
    "price": 12.50,
}
Run Code Online (Sandbox Code Playgroud)

成为

{
    @context{
     test : www.example.com/test/core.json-ld
     test2 : www.example.com/test2/core.json-ld
     }
    "id": 1,
    "test:name": "A green door",
    "test2:price": 12.50,
}
Run Code Online (Sandbox Code Playgroud)

编辑:所以这里是服务期望我的一个例子

{
    "@context": [
        "http://test.net/abcd/contexts/core.jsonld",
        "http://test.net/abcd/contexts/def/4.0/core.jsonld"
    ],

    "startDate": { "@value": "2009-11-21T22:17:10Z", "@type": "xsd:dateTime" },
    "endDate": { "@value": "2005-13-24T22:01:01Z", "@type": "xsd:dateTime" …
Run Code Online (Sandbox Code Playgroud)

java json json-ld

0
推荐指数
1
解决办法
4954
查看次数

如何在网站主页上使用schema.org和JSON-LD标记数据

最近,我读了很多有关使用schema.org标记结构化数据的信息,第一个问题是,建议完全使用它json-ld吗?因为它似乎是新的,尚未得到完全支持。我的第二个问题是在主页或存档页面(通常是其中包含多个文章或产品或博客文章的页面)上,我如何使用schema.org?例如这样的页面:

<!DOCTYPE html>
<html>
    <head>
        <title>Blog Home Page</title>
    </head>

    <body>
        <h1>Blog title</h1>


        <!-- this needs schema.org -->
        <article>
            <h2>Article title</h2>
            Writtem by <span>Authorname</span> on <time datetime="">21 april</time>

            <p>
                Some text
            </p>

            Rated : 
            <div class="star-rate">
                <span class="star full">
                <span class="star full">
                <span class="star full">
                <span class="star half">
                <span class="star empty">
            </div>

            By <span>5</span> users.
        </article>

        <article>
            <h2>Article title</h2>
            Writtem by <span>Authorname</span> on <time datetime="">21 april</time>

            <p>
                Some text
            </p>

            Rated : 
            <div class="star-rate">
                <span class="star full">
                <span class="star …
Run Code Online (Sandbox Code Playgroud)

html5 schema.org json-ld

0
推荐指数
1
解决办法
799
查看次数

使用php-json-ld进行Google AMP的JSONLD

我在使用"php-json-ld"(github.com/digitalbazaar/php-json-ld)打印Google Accelerated Pages(AMP,www.ampproject.org)的正确JSONLD时遇到问题,如本例所示:github.com /ampproject/amphtml/blob/master/examples/metadata-examples/article-json-ld.amp.html

更具体地说:我想知道如何使用php-json-ld的函数添加"@type":"NewsArticle":

    $doc = (object)array(      
    "https://schema.org/article" => 'Article',
    "http://schema.org/name" => "Manu Sporny",
    "http://schema.org/url" => (object)array("@id" =>     "http://manu.sporny.org/"),
    "http://schema.org/image" => (object)array("@id" => "http://manu.sporny.org/images/manu.png")
);

    $context = (object)array(
    "article" => (object)array("https://schema.org/Article"),
    "name" => "http://schema.org/name",
    "homepage" => (object)array("@id" => "http://schema.org/url", "@type" => "@id"),
    "image" => (object)array("@id" => "http://schema.org/image", "@type" => "@id")
);

    //Print Json-LP
    echo '<script type="application/ld+json">';
    echo json_encode($jsonld_compacted, 
                JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
    echo '</script>';

    //Result:
    <script type="application/ld+json">{
       "@context": "http://schema.org",
       "image": "http://manu.sporny.org/images/manu.png",
       "name": "Manu Sporny",
       "url": "http://manu.sporny.org/"
   }</script>
Run Code Online (Sandbox Code Playgroud)

有人可以帮忙吗?

php schema.org json-ld amp-html

0
推荐指数
2
解决办法
3631
查看次数

在 Schema.org JSON-LD 中使用多个相同类型的项目

我正在尝试使用结构化数据来指定多个组织(见下文)。但谷歌的结构化数据测试工具只能识别每种类型的第一项。

如何列出多个alumniOf项目?

<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Organization",
    "name": "My Org",
    "founder": {
      "@type": "Person",
      "name":"Me",
      "alumniOf":{
        "@type": "Organization",
        "name": "My Org 1"
      },
      "alumniOf":{
        "@type": "Organization",
        "name": "My Org 2"
      }

  }
</script>
Run Code Online (Sandbox Code Playgroud)

seo schema.org json-ld

0
推荐指数
1
解决办法
1922
查看次数

RDF语句可以有多个主题吗?

如果你对这个问题的回答是肯定的,你能给我一个使用JSON-LD格式的例子吗?

rdf semantic-web linked-data json-ld

0
推荐指数
2
解决办法
185
查看次数