Skip to content

CLI tool for converting JSON to RDF

License

Apache-2.0, BSD-3-Clause licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
BSD-3-Clause
LICENSE-BSD-3
Notifications You must be signed in to change notification settings

DeciSym/json2rdf

json2rdf

This Rust-based tool converts JSON data into RDF format, utilizing the oxrdf crate for RDF graph handling and serde_json for efficient JSON parsing. It supports lightweight, memory-efficient processing by reading JSON data values sequentially, which makes it suitable for large datasets.

Using the json2rdf CLI

This library includes a CLI utility for parsing JSON and generating N-Triple RDF using the convert subcommand. The binary can be built using cargo build.

$ json2rdf convert --help
Convert JSON to RDF format.

The `convert` command parses a JSON file, converts it to RDF triples using `serde_json` for parsing and `oxrdf` to construct the graph, and saves the output.

Usage: json2rdf convert [OPTIONS] --json-files <JSON_FILES>

Options:
  -n, --namespace <NAMESPACE>
          Namespace for RDF graph generation.

          A custom namespace to prefix RDF resources created from JSON keys and values.

  -j, --json-files <JSON_FILES>
          Path to input JSON file(s).

          Provide the path to one or more JSON files that will be parsed and converted.

  -o, --output-file <OUTPUT_FILE>
          Path to output file.

          Optional: Specify the path to save the generated RDF data.

  -h, --help
          Print help (see a summary with '-h')

Using the convert library

The conversion functionality can also be called directly in Rust. The library supports writing results to a file or building an in-memory oxrdf::Graph.

use json2rdf::json_to_rdf;

// capture conversion results to file
let results = json_to_rdf(&"tests/airplane.json".to_string(), &Some("http://example.com/ns#".to_string()), &Some("output.nt".to_string()));

// capture conversion results to an oxrdf::Graph
let results = json_to_rdf(&"tests/airplane.json".to_string(), &Some("http://example.com/ns#".to_string()), &None);

License

This project is licensed under either of

at your option.

About

CLI tool for converting JSON to RDF

Resources

License

Apache-2.0, BSD-3-Clause licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
BSD-3-Clause
LICENSE-BSD-3

Stars

Watchers

Forks

Packages

No packages published