• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

lanthaler/JsonLD: JSON-LD processor for PHP

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

lanthaler/JsonLD

开源软件地址:

https://github.com/lanthaler/JsonLD

开源编程语言:

PHP 100.0%

开源软件介绍:

JsonLD Build Status

JsonLD is a fully conforming JSON-LD processor written in PHP. It is extensively tested and passes the official JSON-LD test suite.

There's an online playground where you can evaluate the processor's basic functionality.

Additionally to the features defined by the JSON-LD API specification, JsonLD supports framing (including value matching, deep-filtering, aggressive re-embedding, and named graphs) and an experimental object-oriented interface for JSON-LD documents.

Installation

The easiest way to install JsonLD is by requiring it with Composer.

composer require ml/json-ld

... and including Composer's autoloader to your project

require('vendor/autoload.php');

Of course, you can also download JsonLD as ZIP archive from Github.

JsonLD requires PHP 5.3 or later.

Usage

The library supports the official JSON-LD API as well as a object-oriented interface for JSON-LD documents (not fully implemented yet, see issue #15 for details).

All classes are extensively documented. Please have a look at the source code.

// Official JSON-LD API
$expanded = JsonLD::expand('document.jsonld');
$compacted = JsonLD::compact('document.jsonld', 'context.jsonld');
$framed = JsonLD::frame('document.jsonld', 'frame.jsonld');
$flattened = JsonLD::flatten('document.jsonld');
$quads = JsonLD::toRdf('document.jsonld');

// Output the expanded document (pretty print)
print JsonLD::toString($expanded, true);

// Serialize the quads as N-Quads
$nquads = new NQuads();
$serialized = $nquads->serialize($quads);
print $serialized;

// And parse them again to a JSON-LD document
$quads = $nquads->parse($serialized);
$document = JsonLD::fromRdf($quads);

print JsonLD::toString($document, true);

// Node-centric API
$doc = JsonLD::getDocument('document.jsonld');

// get the default graph
$graph = $doc->getGraph();

// get all nodes in the graph
$nodes = $graph->getNodes();

// retrieve a node by ID
$node = $graph->getNode('http://example.com/node1');

// get a property
$node->getProperty('http://example.com/vocab/name');

// add a new blank node to the graph
$newNode = $graph->createNode();

// link the new blank node to the existing node
$node->addPropertyValue('http://example.com/vocab/link', $newNode);

// even reverse properties are supported; this returns $newNode
$node->getReverseProperty('http://example.com/vocab/link');

// serialize the graph and convert it to a string
$serialized = JsonLD::toString($graph->toJsonLd());

Commercial Support

Commercial support is available on request.




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Azure/azure-kubernetes-visualizer: azure-kubernetes-visualizer发布时间:2022-07-09
下一篇:
andrewstuart/vim-kubernetes: vim-kubernetes发布时间:2022-07-09
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap