JsonldEx

Hex.pmDocumentationLicenseBuild Status

🚀 36x faster than pure Elixir JSON-LD implementations

High-performance JSON-LD processing library for Elixir with Rust NIF backend.

Performance

JsonldEx delivers exceptional performance through its Rust-based NIF implementation:

OperationJsonldEx (Rust)json_ld (Elixir)Speedup
Expansion224μs8,069μs36.0x
Compaction~200μs*~7,500μs*~37x*
Flattening~180μs*~6,800μs*~38x*

*Estimated based on expansion benchmarks. Actual results may vary.

Features

Installation

Add jsonld_ex to your list of dependencies in mix.exs:

def deps do
[
{:jsonld_ex, "~> 0.1.0"}
]
end

Quick Start

# Expand a JSON-LD document
doc = %{
"@context" => "https://schema.org/",
"@type" => "Person",
"name" => "Jane Doe",
"age" => 30
}
json_string = Jason.encode!(doc)
{:ok, expanded} = JsonldEx.Native.expand(json_string, [])
# Compact with a context
context = %{"name" => "https://schema.org/name"}
context_string = Jason.encode!(context)
{:ok, compacted} = JsonldEx.Native.compact(expanded, context_string, [])
# Other operations
{:ok, flattened} = JsonldEx.Native.flatten(json_string, nil, [])
{:ok, rdf_data} = JsonldEx.Native.to_rdf(json_string, [])

API Reference

Core Operations

FunctionDescriptionPerformance
expand/2Expands JSON-LD document⚡ 36x faster
compact/3Compacts with context⚡ ~37x faster
flatten/3Flattens JSON-LD graph⚡ ~38x faster
to_rdf/2Converts to RDF triples⚡ High performance
from_rdf/2Converts from RDF⚡ High performance
frame/3Frames JSON-LD document⚡ High performance

Utility Operations

Why Choose JsonldEx?

License

MIT