Extracts a literal value (primitive) from an RDF node
Handles type coercion based on the JSON Schema type:
string
number
integer
boolean
null
The RDF node containing the literal value
The JSON Schema defining the expected type
Extraction context for logging
The extracted and coerced value, or undefined if missing/invalid
// String literalconst name = extractLiteral(node, { type: "string" }, ctx);// → "John Doe"// Number literalconst age = extractLiteral(node, { type: "number" }, ctx);// → 42// Boolean literalconst active = extractLiteral(node, { type: "boolean" }, ctx);// → true Copy
// String literalconst name = extractLiteral(node, { type: "string" }, ctx);// → "John Doe"// Number literalconst age = extractLiteral(node, { type: "number" }, ctx);// → 42// Boolean literalconst active = extractLiteral(node, { type: "boolean" }, ctx);// → true
Extracts a literal value (primitive) from an RDF node
Handles type coercion based on the JSON Schema type:
string: Returns the string value as-isnumber: Parses as float, returns undefined if NaNinteger: Parses as int, returns undefined if NaNboolean: Converts "true"/"false" strings to booleannull: Returns null