Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ubermanu/rdf.zig

RDF Graph parser
https://github.com/ubermanu/rdf.zig

rdf zig

Last synced: about 1 month ago
JSON representation

RDF Graph parser

Awesome Lists containing this project

README

        

# rdf.zig

A RDF Graph parser, supports the following formats:

- N-Triples
- Turtle

## Install

```sh
zig fetch --save git+https://github.com/ubermanu/rdf.zig
```

```zig
const rdf_mod = b.dependency("rdf", .{});
exe.root_module.addImport("rdf", rdf_mod.module("rdf"));
```

## Usage

```zig
const Graph = @import("rdf").Graph;

test {
const graph = Graph.init(std.testing.allocator);
defer graph.deinit();

const ttl =
\\@prefix foaf: .
\\
\\
\\ a foaf:Person ;
\\ foaf:name "Alice" ;
\\ foaf:age "30"^^xsd:integer .
;

graph.loadFromString(ttl);

try std.testing.expectEqualStrings(
"http://example.org/person#Alice",
graph.nodes.items[0].name,
);
}
```