func main() { proc := ld.NewJsonLdProcessor() options := ld.NewJsonLdOptions("") // expanding remote document expanded, err := proc.Expand("http://json-ld.org/test-suite/tests/expand-0002-in.jsonld", options) if err != nil { log.Println("Error when expanding JSON-LD document:", err) return } ld.PrintDocument("JSON-LD expansion succeeded", expanded) // expanding in-memory document doc := make(map[string]interface{}) doc["@context"] = "http://schema.org/" doc["@type"] = "Person" doc["name"] = "Jane Doe" doc["jobTitle"] = "Professor" doc["telephone"] = "(425) 123-4567" doc["url"] = "http://www.janedoe.com" expanded, err = proc.Expand(doc, options) if err != nil { panic(err) } ld.PrintDocument("JSON-LD expansion succeeded", expanded) }
func main() { proc := ld.NewJsonLdProcessor() options := ld.NewJsonLdOptions("") options.Format = "application/nquads" // this JSON-LD document was taken from http://json-ld.org/test-suite/tests/toRdf-0028-in.jsonld doc := map[string]interface{}{ "@context": map[string]interface{}{ "sec": "http://purl.org/security#", "xsd": "http://www.w3.org/2001/XMLSchema#", "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", "dc": "http://purl.org/dc/terms/", "sec:signer": map[string]interface{}{"@type": "@id"}, "dc:created": map[string]interface{}{"@type": "xsd:dateTime"}, }, "@id": "http://example.org/sig1", "@type": []interface{}{"rdf:Graph", "sec:SignedGraph"}, "dc:created": "2011-09-23T20:21:34Z", "sec:signer": "http://payswarm.example.com/i/john/keys/5", "sec:signatureValue": "OGQzNGVkMzVm4NTIyZTkZDYMmMzQzNmExMgoYzI43Q3ODIyOWM32NjI=", "@graph": map[string]interface{}{ "@id": "http://example.org/fact1", "dc:title": "Hello World!", }, } triples, err := proc.ToRDF(doc, options) if err != nil { log.Println("Error when transforming JSON-LD document to RDF:", err) return } os.Stdout.WriteString(triples.(string)) }
func main() { proc := ld.NewJsonLdProcessor() options := ld.NewJsonLdOptions("") expanded, err := proc.Expand("http://json-ld.org/test-suite/tests/expand-0002-in.jsonld", options) if err != nil { log.Println("Error when expanding JSON-LD document:", err) return } ld.PrintDocument("JSON-LD expansion succeeded", expanded) }
*/ package jld import ( "fmt" "net/url" "github.com/develrns/resilient/log" "github.com/kazarena/json-gold/ld" "github.com/pborman/uuid" ) var ( logger = log.Logger() emptyCtx = ld.NewContext(nil, ld.NewJsonLdOptions("")) //IDP is the @id PropID IDP = NewPropID("@id", "") //TypeP is the @type PropID TypeP = NewPropID("@type", "") //IndexP is the @index PropID IndexP = NewPropID("@index", "") //ValueP is the @value PropID ValueP = NewPropID("@value", "") //CtxP is the @context PropID CtxP = NewPropID("@context", "")