piprate / json-gold

A JSON-LD processor for Go
Apache License 2.0
259 stars 30 forks source link

Nested @context definition returns an error #76

Closed MikePlayle closed 1 year ago

MikePlayle commented 1 year ago

Minimal test program:

package main

import (
    "encoding/json"
    "fmt"
    "github.com/piprate/json-gold/ld"
)

var json_text = `{"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"@context":{"PropertyValue":"http://schema.org/#PropertyValue"}}],"id":"https://foo.bar/baz","type":"Group"}`

func main() {
    var json_data map[string]interface{}
    json.Unmarshal([]byte(json_text), &json_data)

    processor := ld.NewJsonLdProcessor()
    options := ld.NewJsonLdOptions("")

    _, err := processor.Expand(json_data, options)
    fmt.Printf("processor.Expand: %s\n", err)
}

Observed result: processor.Expand: keyword redefinition: @context

Expected result: I'm told this is legal, and https://json-ld.org/playground/ accepts it, so json-gold should accept this and return success.

kazarena commented 1 year ago

@MikePlayle, thanks for reporting. Please see the PR above. I'll merge it in a day or two, unless you have any comments.