forked from kazarena/json-gold
-
Notifications
You must be signed in to change notification settings - Fork 1
/
expand.go
41 lines (31 loc) · 852 Bytes
/
expand.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// +build ignore
package main
import (
"github.com/kazarena/json-gold/ld"
"log"
)
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 := map[string]interface{}{
"@context": "http://schema.org/",
"@type": "Person",
"name": "Jane Doe",
"jobTitle": "Professor",
"telephone": "(425) 123-4567",
"url": "http://www.janedoe.com",
}
expanded, err = proc.Expand(doc, options)
if err != nil {
panic(err)
}
ld.PrintDocument("JSON-LD expansion succeeded", expanded)
}