From 0f93516cabea3f09686180873fe32d473bc70270 Mon Sep 17 00:00:00 2001 From: Jaidyn Ann <10477760+JadedCtrl@users.noreply.github.com> Date: Sun, 7 Jul 2024 16:15:29 -0500 Subject: [PATCH] Support terms with ld-keywords as values MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Like “type” → “@type” --- src/json-ld.lisp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/json-ld.lisp b/src/json-ld.lisp index cd61ec4..e5207d0 100644 --- a/src/json-ld.lisp +++ b/src/json-ld.lisp @@ -125,19 +125,21 @@ IRI values whose prefix hasn’t yet been parsed into CTX." (let ((unresolvable '())) (maphash (lambda (term val) - (let* ((iri - (typecase val - (string (when (iri-p val) val)) - (hash-table (gethash "@id" val)))) + (let* ((id (typecase val + (string val) + (hash-table (gethash "@id" val)))) + (iri (when (iri-p id) id)) (uncompacted-iri (ignore-errors (uncompact-iri iri ctx))) + (parsed-id (or uncompacted-iri + (and (ld-keyword-p id) id))) (type (typecase val (string nil) (hash-table (gethash "@type" val))))) - (cond ((and iri (not uncompacted-iri)) + (cond ((and id (not parsed-id)) (push (cons term iri) unresolvable)) (T - (setf (gethash term ctx) (list :id uncompacted-iri :type type)))))) + (setf (gethash term ctx) (list :id parsed-id :type type)))))) table) unresolvable)) @@ -151,7 +153,8 @@ IRI values whose prefix hasn’t yet been parsed into CTX." '("@base" "@container" "@context" "@direction" "@graph" "@id" "@import" "@included" "@index" "@json" "@language" "@list" "@nest" "@none" "@prefix" "@propagate" "@protected" "@reverse" "@set" "@type" - "@value" "@version" "@vocab"))) + "@value" "@version" "@vocab") + :test #'equal)) (defun uncompact-iri (iri ctx) "Given a compacted IRI, uncompact it into its normal form, with CTX being a