This repository has been archived on 2022-11-27. You can view files and clone it, but cannot push or open issues or pull requests.
activitypub/src/jsonld/context.go

28 lines
490 B
Go
Raw Normal View History

package jsonld
import (
"encoding/json"
"activitypub"
)
type Ref string
type Context struct {
URL Ref `jsonld:"_"`
Language activitypub.NaturalLanguageValue `jsonld:"@language,omitempty,collapsible"`
}
func (c *Context) Ref() Ref {
return Ref(c.URL)
}
func (r *Ref) MarshalText() ([]byte, error) {
return []byte(*r), nil
}
2017-10-01 11:43:36 +00:00
func (c *Context) MarshalJSON() ([]byte, error) {
var a map[string]interface{}
a = getMap(c)
return json.Marshal(a)
}