Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,6 @@ _testmain.go

# ignore the EARL report
earl.jsonld

# IDEA GLand
/.idea
61 changes: 46 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,33 @@
[gocover]: https://gocover.io/github.com/piprate/json-gold/ld
[shield-gocover]: https://gocover.io/_badge/github.com/piprate/json-gold/ld

This library is an implementation of the [JSON-LD 1.0](http://json-ld.org/) specification in Go.
This library is an implementation of the [JSON-LD 1.1](http://json-ld.org/) specification in Go.
It supports both URDNA2015 and URGNA2012 RDF dataset normalisation algorithms.

The [original library](https://github.com/kazarena/json-gold) was written by Stan Nazarenko
([@kazarena](https://github.com/kazarena)). See the full list of contributors
[here](https://github.com/piprate/json-gold/blob/master/CONTRIBUTORS.md).

## Testing & Compliance ##

As of December 26, 2018:

* all JSON-LD 1.0 tests from the [official JSON-LD test suite](https://github.com/json-ld/json-ld.org/tree/master/test-suite) pass, with one exception: [framing test #tg010](https://github.com/melville-wiley/json-ld.org/blob/3461fd0005cd8e338cd3729c4714163e9217e619/test-suite/tests/frame-manifest.jsonld#L530). See the discussion [here](https://github.com/json-ld/json-ld.org/pull/663). It appears that while it's meant to be a 1.0 test, the fix in pyLD was implemented in the 1.1 section of the framing code. This needs further investigation.
## Conformance ##

This library aims to pass the official [test suite](https://json-ld.org/test-suite/) and conform with the following:

- [JSON-LD 1.0](http://www.w3.org/TR/2014/REC-json-ld-20140116/),
W3C Recommendation,
2014-01-16, and any [errata](http://www.w3.org/2014/json-ld-errata)
- [JSON-LD 1.0 Processing Algorithms and API](http://www.w3.org/TR/2014/REC-json-ld-api-20140116/),
W3C Recommendation,
2014-01-16, and any [errata](http://www.w3.org/2014/json-ld-errata)
- [JSON-LD 1.1](https://json-ld.org/spec/FCGS/json-ld/20180607/,
Final Community Group Report,
2018-06-07 or [newer JSON-LD latest](https://json-ld.org/spec/latest/json-ld/)
- [JSON-LD 1.1 Processing Algorithms and API](https://json-ld.org/spec/ED/json-ld-api/20180215/),
W3C Editor's Draft,
2018-12-15 or [newer <JSON-LD Processing Algorithms and API latest](https://json-ld.org/spec/latest/json-ld-api/)
- [JSON-LD Framing 1.1](https://json-ld.org/spec/latest/json-ld-framing/)
Draft Community Group Report
2018-09-05 or newer

As of January 1, 2019:

* all JSON-LD 1.0 and 1.1 tests from the [official JSON-LD test suite](https://github.com/json-ld/json-ld.org/tree/master/test-suite) pass, with one exception: [framing test #tg010](https://github.com/melville-wiley/json-ld.org/blob/3461fd0005cd8e338cd3729c4714163e9217e619/test-suite/tests/frame-manifest.jsonld#L530). See the discussion [here](https://github.com/json-ld/json-ld.org/pull/663). This needs further investigation.
* all RDF Dataset Normalisation tests from the [current test suite](https://json-ld.github.io/normalization/tests/index.html) pass
* JSON-LD 1.1 spec is not currenty supported

## Inspiration ##

This implementation was heavily influenced by [JSONLD-Java](https://github.com/jsonld-java/jsonld-java) with some techniques borrowed from [PyLD](https://github.com/digitalbazaar/pyld) and [gojsonld](https://github.com/linkeddata/gojsonld). Big thank you to the contributors of the forementioned libraries for figuring out implementation details of the core algorithms.

## Examples ##

Expand Down Expand Up @@ -65,6 +74,8 @@ See complete code in [examples/compact.go](examples/compact.go).
```go
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1

doc := map[string]interface{}{
"@id": "http://example.org/test#book",
Expand Down Expand Up @@ -94,6 +105,8 @@ See complete code in [examples/flatten.go](examples/flatten.go).
```go
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1

doc := map[string]interface{}{
"@context": []interface{}{
Expand Down Expand Up @@ -125,6 +138,8 @@ See complete code in [examples/frame.go](examples/frame.go).
```go
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1

doc := map[string]interface{}{
"@context": map[string]interface{}{
Expand Down Expand Up @@ -178,6 +193,8 @@ See complete code in [examples/to_rdf.go](examples/to_rdf.go).
```go
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1
options.Format = "application/n-quads"

// this JSON-LD document was taken from http://json-ld.org/test-suite/tests/toRdf-0028-in.jsonld
Expand Down Expand Up @@ -210,6 +227,8 @@ See complete code in [examples/from_rdf.go](examples/from_rdf.go).
```go
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1

triples := `
<http://example.com/Subj1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/Type> .
Expand All @@ -229,6 +248,8 @@ See complete code in [examples/normalize.go](examples/normalize.go).
```go
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1
options.Format = "application/n-quads"
options.Algorithm = "URDNA2015"

Expand All @@ -245,3 +266,13 @@ doc := map[string]interface{}{

normalizedTriples, err := proc.Normalize(doc, options)
```

## Inspiration ##

This implementation was heavily influenced by [JSONLD-Java](https://github.com/jsonld-java/jsonld-java) with some techniques borrowed from [PyLD](https://github.com/digitalbazaar/pyld) and [gojsonld](https://github.com/linkeddata/gojsonld). Big thank you to the contributors of the forementioned libraries for figuring out implementation details of the core algorithms.

## History ##

The [original library](https://github.com/kazarena/json-gold) was written by Stan Nazarenko
([@kazarena](https://github.com/kazarena)). See the full list of contributors
[here](https://github.com/piprate/json-gold/blob/master/CONTRIBUTORS.md).
2 changes: 2 additions & 0 deletions examples/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
func main() {
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1

doc := map[string]interface{}{
"@id": "http://example.org/test#book",
Expand Down
2 changes: 2 additions & 0 deletions examples/expand.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import (
func main() {
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1

// expanding remote document

Expand Down
2 changes: 2 additions & 0 deletions examples/flatten.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
func main() {
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1

doc := map[string]interface{}{
"@context": []interface{}{
Expand Down
2 changes: 2 additions & 0 deletions examples/frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
func main() {
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1

doc := map[string]interface{}{
"@context": map[string]interface{}{
Expand Down
2 changes: 2 additions & 0 deletions examples/from_rdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
func main() {
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1

triples := `
<http://example.com/Subj1> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.com/Type> .
Expand Down
2 changes: 2 additions & 0 deletions examples/normalize.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
func main() {
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1
options.Format = "application/n-quads"
options.Algorithm = "URDNA2015"

Expand Down
2 changes: 2 additions & 0 deletions examples/to_rdf.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import (
func main() {
proc := ld.NewJsonLdProcessor()
options := ld.NewJsonLdOptions("")
// add the processing mode explicitly if you need JSON-LD 1.1 features
options.ProcessingMode = ld.JsonLd_1_1
options.Format = "application/n-quads"

// this JSON-LD document was taken from http://json-ld.org/test-suite/tests/toRdf-0028-in.jsonld
Expand Down
Loading