Skip to content

Accept strings as JSON#92

Description

@adlerfaulkner

Issue type:

  • 馃悰 Bug

Description:

I am getting an error saying:

ErrorResourcesContext: Parameter value "@css:templates/main.html.ejs" is not of required range type "http://www.w3.org/1999/02/22-rdf-syntax-ns#JSON"

From this config:

{
     "@type": "EjsTemplateEngine",
     "EjsTemplateEngine:_template": "@css:templates/main.html.ejs"
}

Because the template arg of EjsTemplateEngine is supposed to be able to accept a string or a json object.

export class EjsTemplateEngine<T extends Dict<any> = Dict<any>> implements TemplateEngine<T> {
  /**
   * @param template - The default template @range {json}
   */
  public constructor(template?: Template) {
  }
}

Using a json field in this way errors because the string cannot be parsed by JSON.parse() here:

case IRIS_RDF.JSON:
try {
parsed = JSON.parse(value.value);
(<any>value.term).valueRaw = parsed;
} catch (error: unknown) {

JSON fields should accept strings because strings are valid JSON.


Environment:

components.js v4.5.0
nodejs v16.14.0

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions