Closed adlerfaulkner closed 2 years ago
Thanks for reporting!
Currently, the CJS generator will only include "@type": "@json"
into type-scoped contexts. So removing --typeScopedContexts
(in pre-3.x), will indeed make it so that JSON values will not become recognised as direct JSON values indeed.
One solution is to wrap your parameter value in the following:
"ex:_myparam": {
"@type": "@json",
"@value": { "somejson": { "somejson": ... } }
}
I see, thanks for the explaination.
Wrapping the parameter value as you suggested resulted in:
Error: Invalid term IRI: @json
Hmm, might be a bug in the parser then. Can you check if you have jsonld-streaming-parser
2.4.3 installed?
If no, could you try updating?
If yes, could you open an issue to report this problem at https://github.com/rubensworks/jsonld-streaming-parser.js ?
I was on version 2.4.0 but after upgrading to 2.4.3 I'm still getting an error for the first field inside the @value
of the json object`:
Cause: Error while parsing file "/Users/adlerfaulkner/community-server/config/app/variables/cli/cli.json": Invalid predicate IRI: config
Error: Error while parsing file "/Users/adlerfaulkner/community-server/config/app/variables/cli/cli.json": Invalid predicate IRI: config
at Function.addPathToError (/Users/adlerfaulkner/community-server/node_modules/componentsjs/lib/rdf/RdfParser.js:73:16)
at PassThrough.<anonymous> (/Users/adlerfaulkner/community-server/node_modules/componentsjs/lib/rdf/RdfParser.js:46:38)
at PassThrough.emit (node:events:532:35)
at JsonLdParser.<anonymous> (/Users/adlerfaulkner/community-server/node_modules/rdf-parse/lib/RdfParser.js:71:47)
at JsonLdParser.emit (node:events:532:35)
at ParsingContext.emitError (/Users/adlerfaulkner/community-server/node_modules/jsonld-streaming-parser/lib/ParsingContext.js:232:21)
at Util.predicateToTerm (/Users/adlerfaulkner/community-server/node_modules/jsonld-streaming-parser/lib/Util.js:437:37)
at EntryHandlerPredicate.validate (/Users/adlerfaulkner/community-server/node_modules/jsonld-streaming-parser/lib/entryhandler/EntryHandlerPredicate.js:90:71)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async JsonLdParser.validateKey (/Users/adlerfaulkner/community-server/node_modules/jsonld-streaming-parser/lib/JsonLdParser.js:320:17)
at async JsonLdParser.newOnValueJob (/Users/adlerfaulkner/community-server/node_modules/jsonld-streaming-parser/lib/JsonLdParser.js:174:62)
at async JsonLdParser.executeBufferedJobs (/Users/adlerfaulkner/community-server/node_modules/jsonld-streaming-parser/lib/JsonLdParser.js:434:13)
I think it's a bug with nested json inside the @value
predicate. I changed my config to the way that it's tested in
https://github.com/rubensworks/jsonld-streaming-parser.js/blob/2c22ac952b67c0a5c5fca61c8c00a7c33c31f52c/test/JsonLdParser-test.ts#L7032-L7046
and it works
{
"@context": [
"https://linkedsoftwaredependencies.org/bundles/npm/@solid/community-server/^3.0.0/components/context.jsonld",
{ "parameters": { "@id": "YargsCliExtractor:_params", "@type": "@json" } }
],
"@graph": [
{
"comment": "Extracts CLI arguments into a key/value object. Config and mainModulePath are only defined here so their description is returned.",
"@id": "urn:solid-server-app-setup:default:CliExtractor",
"@type": "YargsCliExtractor",
"parameters": {
"config": {
"alias": "c",
"requiresArg": true,
"type": "string",
"describe": "The configuration for the server. The default only stores data in memory; to persist to your filesystem, use @css:config/file.json."
},
...
I will create a bug in jsonld-streaming-parser.js
Issue type:
Description:
When I remove
--typeScopedContexts
fromcomponentsjs-generator
in CSS and convert all arguments in the config files to the[Class_name]:_[argument_name]
pattern, I get errors about json fields:For this config:
The jsonld context correctly uses rdf:JSON:
If I change the config file to use the
[Class_name]:_[arg_name]
syntax for the json fields I get the error below:Environment:
componentsjs v4.5.0 componentsjs-generator v2.6.1 node v16.14.0