Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/reiver/go-jsonld
Package jsonld provides JSON-LD encoders and decoders, for the Go programming language. And in particular, handles the way the Fediverse, ActivityPub, and ActivityStreams uses JSON-LD.
https://github.com/reiver/go-jsonld
activitypub activitystreams fediverse json-ld
Last synced: 8 days ago
JSON representation
Package jsonld provides JSON-LD encoders and decoders, for the Go programming language. And in particular, handles the way the Fediverse, ActivityPub, and ActivityStreams uses JSON-LD.
- Host: GitHub
- URL: https://github.com/reiver/go-jsonld
- Owner: reiver
- License: mit
- Created: 2024-12-03T11:25:37.000Z (2 months ago)
- Default Branch: master
- Last Pushed: 2024-12-16T23:56:45.000Z (about 2 months ago)
- Last Synced: 2025-01-01T04:53:30.380Z (about 1 month ago)
- Topics: activitypub, activitystreams, fediverse, json-ld
- Language: Go
- Homepage:
- Size: 60.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-jsonld
Package **jsonld** provides JSON-LD encoders and decoders, for the Go programming language.
And in particular, handles the way the Fediverse, ActivityPub, and ActivityStreams uses JSON-LD.
And import thing to understand is — you use separate Go `struct`s to represent each JSON-LD namespace.
Both for _marshaling_ and _unmarshaing_.## Documention
Online documentation, which includes examples, can be found at: http://godoc.org/github.com/reiver/go-jsonld
[![GoDoc](https://godoc.org/github.com/reiver/go-jsonld?status.svg)](https://godoc.org/github.com/reiver/go-jsonld)
## Example
Here is a simple example with only one JSON-LD namespace:
```golang
import "github.com/reiver/go-jsonld"// ...
// Note that "jsonld" struct-tags are used on the first 2 fields,
// and "json" struct-tags are used on the rest of the fields.
type MyStruct struct {
NameSpace jsonld.NameSpace `jsonld:"http://example.com/ns"`
Prefix jsonld.Prefix `jsonld:"ex"`Once bool `json:"once"`
Twice int `json:"twice"`
Thrice string `json:"thrice,omitempty"`
Fource uint `json:"fource"`
}// ...
var value MyStruct // = ...
bytes, err := jsonld.Marshal(value)
```Here is a more typical example with multiple JSON-LD namespaces.
```golang
import "github.com/reiver/go-jsonld"// ...
type Person struct {
NameSpace jsonld.NameSpace `jsonld:"http://ns.example/person"`
Prefix jsonld.Prefix `jsonld:"person"`GivenName string `json:"given-name,omitempty"`
AdditionalNames []string `json:"additional-names,omitempty"`
FamilyName string `json:"family-name,omitempty"`
}type Programmer struct {
NameSpace jsonld.NameSpace `jsonld:"http://example.com/programmer"`
Prefix jsonld.Prefix `jsonld:"programmer"`ProgrammingLanguage string `json:"programming-language,omitempty"`
}// ...
var person Person // = ...
var programmer Programmer // = ...bytes, err := jsonld.Marshal(person, programmer)
```## Import
To import package **jsonld** use `import` code like the follownig:
```
import "github.com/reiver/go-jsonld"
```## Installation
To install package **jsonld** do the following:
```
GOPROXY=direct go get github.com/reiver/go-jsonld
```## Author
Package **jsonld** was written by [Charles Iliya Krempeaux](http://reiver.link)