cubicweb的jsonld视图

cubicweb-jsonld的Python项目详细描述


摘要

jsonldcubicweb视图

视图

这个多维数据集提供了一个具有两种不同实现的jsonld视图。

cwetype

的jsonld

CWEType实体的jsonld视图也可以访问 显式地或通过BASE_URL/<etype>.jsonldurl。它提供了 使用jsonld规范的模式信息。

假设您有以下架构声明:

class Person(EntityType):
    name = String()
    age = Int()
    birthdate = Date()

相应的jsonld输出为:

{
    "@context": {
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "creation_date": {
          "@id": "https://my-app.org/CWRType/creation_date",
          "@type": "xsd:dateTime"
        },
        "modification_date": {
          "@id": "https://my-app.org/CWRType/modification_date",
          "@type": "xsd:dateTime"
        },
        "cwuri": {
          "@id": "https://my-app.org/CWRType/cwuri",
          "@type": "@id"
        },
        "eid": {
          "@id": "https://my-app.org/CWRType/eid",
          "@type": "xsd:integer"
        },
        "name": {
          "@id": "https://my-app.org/CWAttribute/278",
          "@type": "xsd:string"
        },
        "age": {
          "@id": "https://my-app.org/CWAttribute/281",
          "@type": "xsd:string"
        },
        "birthdate": {
          "@id": "https://my-app.org/CWAttribute/301",
          "@type": "xsd:date"
        }
    }
}

jsonld用于任何rset

这个视图有点类似于标准的jsonexportone 有两个主要区别:

  • 它在实际数据和 尽量接近 sparql-results-json格式,
  • 每个单元格都公开为“jsonld”对象。实体公开 它们的所有属性和dc属性,“final”值公开 他们的类型和价值。

考虑rql查询Any P,N LIMIT 2 WHERE P is Person, P name N, jsonld输出如下:

{
    "@context": {
        "cw": "http://ns.cubicweb.org/cubicweb/0.0/",
        "xsd": "http://www.w3.org/2001/XMLSchema#",
        "dcterms": "http://purl.org/dc/terms/",
        "myapp": "https://my-app.org/CWEType/"
    },
    "cw:head": {
        "rql": "Any P,N LIMIT 2 WHERE P is Person, P name N",
        "vars": ["P", "N"],
        "limit": 2
    },
    "cw:results": [
        [{
            "@context": "https://my-app.org/Person.jsonld",
            "@type": "myapp:Person",
            "cwuri": "https://my-app.org/1234",
            "name": "John",
            "age": 42,
            "birthdate": "2013/01/01",
            "creation_date": "2009/08/07 15:20:30",
            "modification_date": "2009/08/05 11:12:24",
            "eid": 1234,
            "dcterms:title": "the result of p.dc_title() on John",
            "dcterms:description": null
        },
        {
            "@type": "xsd:string",
            "@value": "John"
        }],
       [{
            "@context": "https://my-app.org/Person.jsonld",
            "@type": "myapp:Person",
            "cwuri": "https://my-app.org/4321",
            "name": "Mary",
            "age": 40,
            "birthdate": "2015/02/02",
            "creation_date": "2014/01/02 11:30:20",
            "modification_date": "2015/01/05 12:24:11",
            "eid": 4321,
            "dcterms:title": "the result of p.dc_title() on Mary",
            "dcterms:description": null
       },
        {
            "@type": "xsd:string",
            "@value": "Mary"
        }]
    ]
}

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
MIME类型多部分/混合的java无对象DCH   Java Swing中单元格和列的间距   java为什么我不能使用For循环从集合中获取元素?   mysql Java餐厅计费系统   java MediaPlayer内存消耗   println Java添加的神秘输出:一些经过评估,一些经过打印   java我应该使用哪个对象?   PHP到Java论坛游戏集成   通过GeoNetwork上的java http post请求获取XML响应   java为什么类名与使用“==”的内部字符串比较冲突?   java反应。js如何定义自定义id,而不是在html中显示reactselect1value   java中的拼字数组   java如何使ScheduledExecutorService在其计划任务取消时自动终止   java查询未正确执行   IBatis+Java:检索HashMap   要读取的加密Java代码。txt文件并转换为二进制表示形式   Java Web Start应用程序自动加载   java Swing重写对象的paintComponent