Closed fils closed 2 years ago
It seems a \ will resolve it as in
if strings.HasPrefix(k, "@") {
tns = fmt.Sprintf("@context.\\%s", k)
} else {
tns = fmt.Sprintf("@context.%s", k)
}
not sure if this is really the best way but seems to be holding up to testing..
Thanks for reporting. I figured out what the issue was and fixed it.
The gjson library (which sjson uses to find where to replace the new values from sjson.Set
) did not allow for changing values for modifier path components, which start with the @
character. I made an update to gjson to check that that path component was an actual known modifier. 😅
I trying to write a line where I update a context entry in a JSON-LD document. The schema.org context is often either https://schema.org or http://schema.org. This is some code to normalize them to a value.
In the code at https://github.com/gleanerio/gleaner/blob/df--dev/tools/contextChange/main.go line 118 I have
When this has a value for tns like:
It will not update the JSON document (they are in the data directory next to the go main file)
if it is
it entry is found and updated.
It seems is the second element have an @ keyword prefix (ie, the @vocab) cause sjon to not find the entry.
Any guidance is appreciated