piprate/json-gold

Nested @context definition returns an error

MikePlayle opened this issue · 1 comments

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.

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