JSON-LD.ex alternatives and similar packages
Based on the "JSON" category.
Alternatively, view JSON-LD.ex alternatives based on common mentions on social networks and blogs.
-
json_pointer
Implementation of RFC 6901 which defines a string syntax for identifying a specific value within a JSON document -
jwalk
Helper module for working with Erlang proplists, eep 18, map and mochijson-style JSON representations
WorkOS - The modern identity platform for B2B SaaS
Do you think we are missing an alternative of JSON-LD.ex or a related project?
README
JSON-LD.ex
An implementation of the JSON-LD standard for Elixir and RDF.ex.
Features
- fully conforming JSON-LD API processor
- JSON-LD reader/writer for RDF.ex
- tests of the JSON-LD test suite (see here for a detailed status report)
TODO
- JSON-LD Framing
- JSON-LD 1.1 support
Installation
The JSON-LD.ex Hex package can be installed as usual, by adding json_ld
to your list of dependencies in mix.exs
:
def deps do
[{:json_ld, "~> 0.3"}]
end
Usage
Expand a document
"""
{
"@context":
{
"name": "http://xmlns.com/foaf/0.1/name",
"homepage": {
"@id": "http://xmlns.com/foaf/0.1/homepage",
"@type": "@id"
}
},
"name": "Manu Sporny",
"homepage": "http://manu.sporny.org/"
}
"""
|> Jason.decode!
|> JSON.LD.expand
produces
[%{"http://xmlns.com/foaf/0.1/homepage" => [%{"@id" => "http://manu.sporny.org/"}],
"http://xmlns.com/foaf/0.1/name" => [%{"@value" => "Manu Sporny"}]}]
Compact a document
context = Jason.decode! """
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"homepage": {
"@id": "http://xmlns.com/foaf/0.1/homepage",
"@type": "@id"
}
}
}
"""
"""
[
{
"http://xmlns.com/foaf/0.1/name": [ "Manu Sporny" ],
"http://xmlns.com/foaf/0.1/homepage": [
{
"@id": "http://manu.sporny.org/"
}
]
}
]
"""
|> Jason.decode!
|> JSON.LD.compact(context)
produces
%{"@context" => %{
"homepage" => %{
"@id" => "http://xmlns.com/foaf/0.1/homepage",
"@type" => "@id"},
"name" => "http://xmlns.com/foaf/0.1/name"
},
"homepage" => "http://manu.sporny.org/",
"name" => "Manu Sporny"}
RDF Reader and Writer
JSON-LD.ex can be used to serialize or deserialize RDF graphs by using it as a RDF.ex reader and writer.
dataset = JSON.LD.read_file!("file.jsonld")
JSON.LD.write_file!(dataset, "file.jsonld")
Pretty printing
Pretty printing is possible on all writer functions with all of the formatter options of Jason, the underlying JSON encoder, to which the given options are passed through.
JSON.LD.write_file!(dataset, "file.jsonld", pretty: true)
JSON.LD.write_string(dataset, "file.jsonld", pretty: [indent: "\t"])
Getting help
Contributing
see [CONTRIBUTING](CONTRIBUTING.md) for details.
License and Copyright
(c) 2017-2020 Marcel Otto. MIT Licensed, see [LICENSE](LICENSE.md) for details.
*Note that all licence references and agreements mentioned in the JSON-LD.ex README section above
are relevant to that project's source code only.