@frogcat/ttl2jsonld

中文文档
0.0.11发布于 2026/10/15MITCommonJS零依赖近 30 天下载 8.1万

Turtle 到 JSON- LD 节点和浏览器的转换器, 没有库依赖性

中文使用文档
文档目录13 节
  1. 演示
  2. 输入龟
  3. 产出JSON-LD
  4. 安装
  5. 节点.js
  6. 浏览器
  7. 使用量
  8. 节点.js
  9. 浏览器
  10. API 密码
  11. 对于开发者
  12. 大楼
  13. 测试

@frogcat/ttl2jsonld (英语)

Turtle to JSON-LD 用于节点.js和浏览器的转换器,没有库依赖性.

演示

可在线演示 这里。 。 。 .

使用此转换器,您可以获取 Output JSON-LD 从 Input Turtle,如 JSON-LD 1.0 规格 。 。 。 .

输入龟

@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<http://manu.sporny.org/about#manu> a foaf:Person;
  foaf:name "Manu Sporny";
  foaf:homepage <http://manu.sporny.org/> .

产出JSON-LD

{
  "@context": {
    "foaf": "http://xmlns.com/foaf/0.1/"
  },
  "@id": "http://manu.sporny.org/about#manu",
  "@type": "foaf:Person",
  "foaf:name": "Manu Sporny",
  "foaf:homepage": { "@id": "http://manu.sporny.org/" }
}

安装

节点.js

$ npm install @frogcat/ttl2jsonld

浏览器

<script src="https://frogcat.github.io/ttl2jsonld/ttl2jsonld.js"></script>

使用量

节点.js

你可以自己写代码.

const ttl2jsonld = require('@frogcat/ttl2jsonld').parse;

const ttl = `@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<http://manu.sporny.org/about#manu> a foaf:Person;
  foaf:name "Manu Sporny";
  foaf:homepage <http://manu.sporny.org/> .
`;

const jsonld = ttl2jsonld(ttl);

console.log(JSON.stringify(jsonld,null,2));

命令行接口也可用.

$ npm install @frogcat/ttl2jsonld
$ ttl2jsonld {input_turtle} > {output_jsonld}
or
$ cat {input_turtle} | ttl2jsonld > {output_jsonld}

浏览器

此转换器被导出到 ttl2jsonld 全球对象。 打电话 ttl2jsonld.parse(ttl) 用于进行转换.

<!-- include ttl2jsonld.js -->
<script src="https://frogcat.github.io/ttl2jsonld/ttl2jsonld.js"></script>

<!-- run script -->
<script>
const ttl = `@prefix foaf: <http://xmlns.com/foaf/0.1/> .

<http://manu.sporny.org/about#manu> a foaf:Person;
  foaf:name "Manu Sporny";
  foaf:homepage <http://manu.sporny.org/> .
`;

const jsonld = ttl2jsonld.parse(ttl);

console.log(JSON.stringify(jsonld,null,2));
</script>

API 密码

鉴于 turtle_string, (中文(简体) ), ttl2jsonld.parse 返回 JSON 对象.

var json_object = ttl2jsonld.parse(turtle_string);

想要通过BaseIRI时,请像这样给出第二个论证.

var json_object = ttl2jsonld.parse(turtle_string, {
  baseIRI : "http://example.org/"
});

对于开发者

大楼

  • 以 国家。 。 。 .
  • 主代码为 spec/ttl2jsonld.pegjs。 。 。 .
  • 编辑代码时,运行 npm run build 生成 ttl2jsonld.js。 。 。 .

测试

版本与发布记录

@frogcat/ttl2jsonld 共发布 11 个版本,首次发布于 2019/06/03;过去 12 个月发布了 1 个版本。

版本发布日期距今
0.0.11latest2026/10/151 个月前
0.0.102025/01/151.8 年前
0.0.92023/01/263 年前
0.0.82022/03/244 年前
0.0.72022/02/174 年前
0.0.62020/07/176 年前

关于 @frogcat/ttl2jsonld 的常见问题

@frogcat/ttl2jsonld 是什么?

Turtle 到 JSON- LD 节点和浏览器的转换器, 没有库依赖性

如何安装 @frogcat/ttl2jsonld?

在项目目录运行 npm install @frogcat/ttl2jsonld,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 ttl2jsonld,可以用 npx ttl2jsonld 直接运行。

@frogcat/ttl2jsonld 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/frogcat__ttl2jsonld 是否存在。

@frogcat/ttl2jsonld 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@frogcat/ttl2jsonld 可以商用吗?

@frogcat/ttl2jsonld 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@frogcat/ttl2jsonld 的下载量有多少?

根据 npm 官方下载统计,@frogcat/ttl2jsonld 在 2026/10/16 – 2026/11/14 这 30 天内被下载 80,769 次,日均约 2,692 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@frogcat/ttl2jsonld 还在维护吗?

最新版本 0.0.11 发布于 2026/10/15(1 个月前);至今共发布 11 个版本,其中过去 12 个月发布了 1 个;首次发布于 2019/06/03。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。