Update to guile-json-4
guix.scm
48 | 48 | (inputs | |
49 | 49 | `(("guile" ,guile-3.0) | |
50 | 50 | ("guile-gnutls" ,gnutls) | |
51 | - | ("guile-json" ,guile-json-3) | |
51 | + | ("guile-json" ,guile-json-4) | |
52 | 52 | ("guile-rdf" ,guile-rdf))) | |
53 | 53 | (native-inputs | |
54 | 54 | `(("automake" ,automake) |
jsonld.scm
53 | 53 | ;; 4 | |
54 | 54 | (when (json-has-key? context "@context") | |
55 | 55 | (set! context (assoc-ref context "@context"))) | |
56 | + | (pk expanded-input) | |
57 | + | (pk context) | |
56 | 58 | (let* ((base-iri (or (jsonld-options-base options) | |
57 | 59 | (and (jsonld-options-compact-to-relative? options) | |
58 | 60 | (string? input) | |
… | |||
64 | 66 | (inverse-context (inverse-context-creation active-context)) | |
65 | 67 | (compacted-output | |
66 | 68 | (compaction active-context inverse-context | |
67 | - | #nil ;; active-property | |
69 | + | json-null ;; active-property | |
68 | 70 | expanded-input ;; element | |
69 | 71 | #:compact-arrays? (jsonld-options-compact-arrays? options) | |
70 | 72 | #:ordered? (jsonld-options-ordered? options) | |
71 | 73 | #:processing-mode | |
72 | 74 | (jsonld-options-processing-mode options)))) | |
75 | + | (pk 'compacted-output compacted-output) | |
73 | 76 | (if (equal? compacted-output #()) | |
74 | 77 | (set! compacted-output '()) | |
75 | 78 | (when (json-array? compacted-output) | |
… | |||
135 | 138 | (context-processing active-context context-url context-url)))) | |
136 | 139 | ||
137 | 140 | ;; 7 | |
138 | - | (let ((expanded-output (expansion active-context #nil document | |
141 | + | (let ((expanded-output (expansion active-context json-null document | |
139 | 142 | (if remote-document | |
140 | 143 | (or (json-document-document-url remote-document) | |
141 | 144 | (jsonld-options-base options)) | |
… | |||
149 | 152 | (not (equal? (car kv) "@graph"))) | |
150 | 153 | expanded-output))) | |
151 | 154 | (set! expanded-output (assoc-ref expanded-output "@graph"))) | |
152 | - | (when (equal? expanded-output #nil) | |
155 | + | (when (json-null? expanded-output) | |
153 | 156 | (set! expanded-output #())) | |
154 | 157 | (unless (json-array? expanded-output) | |
155 | 158 | (set! expanded-output `#(,expanded-output))) |
jsonld/compaction.scm
52 | 52 | ||
53 | 53 | (define* (compaction active-context inverse-context active-property element | |
54 | 54 | #:key (compact-arrays? #f) (ordered? #f) processing-mode) | |
55 | + | (pk 'compaction element) | |
55 | 56 | ;; 1 | |
56 | 57 | (let ((type-scoped-context active-context) | |
57 | 58 | (def (term-definition-ref active-context active-property))) | |
… | |||
73 | 74 | #:ordered? ordered? | |
74 | 75 | #:processing-mode processing-mode))) | |
75 | 76 | ;; 3.2.2 | |
76 | - | (unless (equal? compacted-item #nil) | |
77 | + | (unless (json-null? compacted-item) | |
77 | 78 | (set! result (cons compacted-item result))))) | |
78 | 79 | (array->list element)) | |
79 | 80 | (set! result (reverse result)) | |
… | |||
92 | 93 | ;; 4 | |
93 | 94 | (else | |
94 | 95 | ;; 5 | |
95 | - | (when (active-context-previous active-context) | |
96 | + | (when (not-null-or-false (active-context-previous active-context)) | |
96 | 97 | (unless (or (json-has-key? element "@value") | |
97 | 98 | (and (json-has-key? element "@id") | |
98 | 99 | (null? (filter (lambda (kp) (not (equal? (car kp) "@id"))) | |
… | |||
100 | 101 | (set! active-context (active-context-previous active-context)) | |
101 | 102 | (set! inverse-context (inverse-context-creation active-context)))) | |
102 | 103 | ;; 6 | |
103 | - | (when (and def (term-definition-context def)) | |
104 | + | (when (and (term-definition? def) | |
105 | + | (not-null-or-false (term-definition-context def))) | |
104 | 106 | ;; 6.1 | |
105 | 107 | (set! active-context | |
106 | 108 | (context-processing active-context (term-definition-context def) | |
… | |||
116 | 118 | (value-compaction active-context inverse-context | |
117 | 119 | active-property element processing-mode))) | |
118 | 120 | (or (scalar? compact) | |
119 | - | (and def (equal? (term-definition-type def) "@json"))))) | |
121 | + | (and (term-definition? def) | |
122 | + | (equal? (term-definition-type def) "@json"))))) | |
120 | 123 | (value-compaction active-context inverse-context active-property | |
121 | 124 | element processing-mode)) | |
122 | 125 | ;; 8 | |
… | |||
142 | 145 | (iri-compaction active-context inverse-context type | |
143 | 146 | #:vocab? #t #:processing-mode processing-mode)) | |
144 | 147 | types))) | |
148 | + | (pk 'compacted-types compacted-types) | |
145 | 149 | (for-each | |
146 | 150 | (lambda (term) | |
147 | 151 | ;; 11.1 | |
148 | 152 | (when (and | |
149 | - | (term-definition-ref type-scoped-context term) | |
153 | + | (term-definition? (term-definition-ref type-scoped-context term)) | |
150 | 154 | (term-definition-context | |
151 | 155 | (term-definition-ref type-scoped-context term))) | |
152 | 156 | ;; 11.1.1 | |
… | |||
182 | 186 | (cond | |
183 | 187 | ;; 12.1 | |
184 | 188 | ((equal? expanded-property "@id") | |
189 | + | (pk 'expanded-value expanded-value) | |
185 | 190 | ;; XXX: not clear what to do if expanded-value is not a | |
186 | 191 | ;; string, make sure there is a test | |
187 | 192 | (let ((compacted-value | |
… | |||
191 | 196 | expanded-value)) | |
192 | 197 | (alias (iri-compaction active-context inverse-context expanded-property | |
193 | 198 | #:vocab? #t #:processing-mode processing-mode))) | |
199 | + | (pk 'compacted-value compacted-value) | |
200 | + | (pk 'alias alias) | |
194 | 201 | (set! result | |
195 | 202 | (alist-set result alias compacted-value)))) | |
196 | 203 | ;; 12.2 | |
… | |||
206 | 213 | (not compact-arrays?))) | |
207 | 214 | (type-scoped-inverse-context | |
208 | 215 | (inverse-context-creation type-scoped-context))) | |
216 | + | (pk 'alias alias) | |
209 | 217 | (if (string? expanded-value) | |
210 | 218 | (set! compacted-value | |
211 | 219 | (iri-compaction type-scoped-context type-scoped-inverse-context | |
… | |||
217 | 225 | (list->array 1 | |
218 | 226 | (map | |
219 | 227 | (lambda (v) | |
220 | - | (iri-compaction type-scoped-context type-scoped-inverse-context | |
228 | + | (pk 'v (iri-compaction type-scoped-context type-scoped-inverse-context | |
221 | 229 | v | |
222 | - | #:vocab? #t #:processing-mode processing-mode)) | |
230 | + | #:vocab? #t #:processing-mode processing-mode))) | |
223 | 231 | expanded-value))))) | |
232 | + | (pk 'compacted-value compacted-value) | |
224 | 233 | (when (and (json-array? compacted-value) (= (array-length compacted-value) 1)) | |
225 | 234 | (set! compacted-value (car (array->list compacted-value)))) | |
226 | 235 | (set! result | |
… | |||
234 | 243 | (for-each-pair | |
235 | 244 | (lambda (property value) | |
236 | 245 | (let ((def (term-definition-ref active-context property))) | |
237 | - | (when (and def (term-definition-reverse? def)) | |
246 | + | (when (and (term-definition? def) (term-definition-reverse? def)) | |
238 | 247 | (let ((as-array? (or | |
239 | 248 | (member "@set" | |
240 | 249 | (container-mapping active-context property)) | |
… | |||
248 | 257 | (unless (null? compacted-value) | |
249 | 258 | (let ((alias (iri-compaction active-context inverse-context "@reverse" | |
250 | 259 | #:vocab? #t #:processing-mode processing-mode))) | |
260 | + | (pk 'alias alias) | |
251 | 261 | (set! result (alist-set result alias compacted-value)))))) | |
252 | 262 | ;; 12.4 | |
253 | 263 | ((equal? expanded-property "@preserve") | |
… | |||
269 | 279 | (equal? expanded-property "@value")) | |
270 | 280 | (let ((alias (iri-compaction active-context inverse-context expanded-property | |
271 | 281 | #:vocab? #t #:processing-mode processing-mode))) | |
282 | + | (pk 'alias alias) | |
272 | 283 | (set! result | |
273 | 284 | (alist-set result alias expanded-value)))) | |
274 | 285 | (else | |
… | |||
282 | 293 | #:processing-mode processing-mode)) | |
283 | 294 | (def (term-definition-ref active-context | |
284 | 295 | item-active-property)) | |
285 | - | (nest-term (if def (term-definition-nest def) #f)) | |
296 | + | (nest-term (if (term-definition? def) (term-definition-nest def) #f)) | |
286 | 297 | ;; 12.7.4 | |
287 | 298 | (nest-result result)) | |
299 | + | (pk 'item-active-property item-active-property) | |
288 | 300 | ;; 12.7.2 | |
289 | 301 | (when nest-term | |
290 | 302 | (unless (or (equal? nest-term "@nest") | |
… | |||
310 | 322 | #:reverse? inside-reverse? | |
311 | 323 | #:processing-mode processing-mode)) | |
312 | 324 | (def (term-definition-ref active-context item-active-property)) | |
313 | - | (nest-term (if def (term-definition-nest def) #f)) | |
325 | + | (nest-term (if (term-definition? def) (term-definition-nest def) #f)) | |
314 | 326 | ;; 12.8.3 | |
315 | 327 | (nest-result result) | |
316 | 328 | ;; 12.8.4 | |
… | |||
323 | 335 | ;; 12.8.6 | |
324 | 336 | (compacted-item | |
325 | 337 | (compaction active-context inverse-context item-active-property | |
326 | - | (if (json-has-key? expanded-item | |
327 | - | "@list") | |
338 | + | (if (json-has-key? expanded-item "@list") | |
328 | 339 | (assoc-ref expanded-item "@list") | |
329 | 340 | (if (graph-object? expanded-item) | |
330 | 341 | (assoc-ref expanded-item "@graph") | |
331 | 342 | expanded-item)) | |
332 | 343 | #:compact-arrays? compact-arrays? | |
333 | 344 | #:ordered? ordered?))) | |
345 | + | (pk 'item-active-property item-active-property) | |
334 | 346 | ;; 12.8.2 | |
335 | - | (when nest-term | |
347 | + | (when (not-null-or-false nest-term) | |
336 | 348 | (unless (or (equal? nest-term "@nest") | |
337 | 349 | (equal? (expand-key active-context nest-term) "@nest")) | |
338 | 350 | (throw 'invalid-@nest-value)) | |
… | |||
376 | 388 | ((and (member "@id" container) | |
377 | 389 | (member "@graph" container)) | |
378 | 390 | (let* ((map-object | |
379 | - | (or (assoc-ref nest-result item-active-property) '())) | |
391 | + | (or (not-null-or-false (assoc-ref nest-result item-active-property)) '())) | |
380 | 392 | (map-key | |
381 | 393 | (if (json-has-key? expanded-item "@id") | |
382 | 394 | (assoc-ref expanded-item "@id") | |
… | |||
397 | 409 | (member "@index" container) | |
398 | 410 | (simple-graph-object? expanded-item)) | |
399 | 411 | (let ((map-object | |
400 | - | (or (assoc-ref nest-result item-active-property) '())) | |
412 | + | (or (not-null-or-false (assoc-ref nest-result item-active-property)) '())) | |
401 | 413 | (map-key | |
402 | 414 | (if (json-has-key? expanded-item "@index") | |
403 | 415 | (assoc-ref expanded-item "@index") | |
… | |||
471 | 483 | ((member "@id" container) "@id") | |
472 | 484 | (else "@type")) | |
473 | 485 | #:vocab? #t)) | |
474 | - | (map-key #nil) | |
486 | + | (map-key json-null) | |
475 | 487 | ;; 12.8.9.3 | |
476 | 488 | (def (term-definition-ref active-context item-active-property)) | |
477 | - | (index-key (or (and def (term-definition-index def)) "@index"))) | |
489 | + | (index-key (or (and (term-definition? def) | |
490 | + | (term-definition-index def)) | |
491 | + | "@index"))) | |
478 | 492 | (cond | |
479 | 493 | ;; 12.8.9.4 | |
480 | 494 | ((and (member "@language" container) | |
481 | - | (json-has-key? expanded-item "@value")) | |
495 | + | (json-has-key? expanded-item "@value")) | |
482 | 496 | (set! compacted-item (assoc-ref expanded-item "@value")) | |
483 | 497 | (when (json-has-key? expanded-item "@language") | |
484 | 498 | (set! map-key (assoc-ref expanded-item "@language")))) | |
… | |||
498 | 512 | (keys (if (json-array? keys) | |
499 | 513 | (array->list keys) | |
500 | 514 | (list keys))) | |
501 | - | (key (and (not (null? keys)) (car keys))) | |
515 | + | (key (and (not (null? keys)) (not-null-or-false (car keys)))) | |
502 | 516 | (remaining (if key (cdr keys) '()))) | |
503 | 517 | (when key | |
504 | 518 | (unless (string? key) | |
… | |||
527 | 541 | (keys (if (json-array? keys) | |
528 | 542 | (array->list keys) | |
529 | 543 | (list keys))) | |
530 | - | (key (and (not (null? keys)) (car keys))) | |
544 | + | (key (and (not (null? keys)) (not-null-or-false (car keys)))) | |
531 | 545 | (remaining (if key (cdr keys) '()))) | |
532 | 546 | ;; 12.8.9.8.1 | |
533 | - | (when key | |
547 | + | (when (not-null-or-false key) | |
534 | 548 | (set! map-key key)) | |
535 | 549 | ;; 12.8.9.8.2 | |
536 | 550 | (if (null? remaining) | |
… | |||
550 | 564 | active-context inverse-context item-active-property | |
551 | 565 | `(("@id" . ,(assoc-ref expanded-item "@id"))))))))) | |
552 | 566 | ;; 12.8.9.9 | |
553 | - | (when (equal? map-key #nil) | |
567 | + | (when (json-null? map-key) | |
554 | 568 | (set! map-key (iri-compaction active-context inverse-context | |
555 | 569 | "@none" #:vocab? #t))) | |
556 | 570 | ;; 12.8.9.10 |
jsonld/context-processing.scm
45 | 45 | (when (json-has-key? local-context "@propagate") | |
46 | 46 | (set! propagate? (assoc-ref local-context "@propagate"))) | |
47 | 47 | ;; 3 | |
48 | - | (unless (or propagate? (active-context-previous active-context)) | |
48 | + | (unless (or propagate? (not-null-or-false (active-context-previous active-context))) | |
49 | 49 | (set! result (update-active-context result #:previous active-context))) | |
50 | 50 | ;; 4 | |
51 | 51 | (if (json-array? local-context) | |
… | |||
56 | 56 | (lambda (context) | |
57 | 57 | (match context | |
58 | 58 | ;; 5.1 | |
59 | - | (#nil | |
59 | + | ((? json-null? null) | |
60 | 60 | (unless (or override-protected? | |
61 | 61 | (null? (filter | |
62 | 62 | term-definition-protected? | |
… | |||
155 | 155 | (let ((value (assoc-ref context "@base"))) | |
156 | 156 | (cond | |
157 | 157 | ;; 5.7.2 | |
158 | - | ((equal? value #nil) | |
159 | - | (set! result (update-active-context result #:base #nil))) | |
158 | + | ((json-null? value) | |
159 | + | (set! result (update-active-context result #:base json-null))) | |
160 | 160 | ;; 5.7.3 | |
161 | 161 | ((absolute-iri? value) | |
162 | 162 | (set! result (update-active-context result #:base value))) | |
163 | 163 | (else | |
164 | 164 | (let ((iri (resolve-iri (active-context-base result) value))) | |
165 | 165 | (if (and (absolute-iri? iri) | |
166 | - | (active-context-base result)) | |
166 | + | (not-null-or-false (active-context-base result))) | |
167 | 167 | ;; 5.7.4 | |
168 | 168 | (set! result (update-active-context result #:base iri)) | |
169 | 169 | ;; 5.7.5 | |
… | |||
173 | 173 | (when (json-has-key? context "@vocab") | |
174 | 174 | ;; 5.8.1 | |
175 | 175 | (let ((value (assoc-ref context "@vocab"))) | |
176 | - | (if (equal? value #nil) | |
176 | + | (if (json-null? value) | |
177 | 177 | ;; 5.8.2 | |
178 | 178 | (set! result (update-active-context result #:vocab #f)) | |
179 | 179 | ;; 5.8.3 | |
… | |||
191 | 191 | (when (json-has-key? context "@language") | |
192 | 192 | ;; 5.9.1 | |
193 | 193 | (let ((value (assoc-ref context "@language"))) | |
194 | - | (if (equal? value #nil) | |
194 | + | (if (json-null? value) | |
195 | 195 | ;; 5.9.2 | |
196 | 196 | (set! result (update-active-context result #:language #f)) | |
197 | 197 | ;; 5.9.3 | |
… | |||
205 | 205 | (when (processing-mode-1.0? (jsonld-options-processing-mode options)) | |
206 | 206 | (throw 'invalid-context-entry)) | |
207 | 207 | (let ((value (assoc-ref context "@direction"))) | |
208 | - | (if (equal? value #nil) | |
208 | + | (if (json-null? value) | |
209 | 209 | ;; 5.10.2 | |
210 | 210 | (set! result (update-active-context result #:direction #f)) | |
211 | 211 | ;; 5.10.3 |
jsonld/context.scm
17 | 17 | ||
18 | 18 | (define-module (jsonld context) | |
19 | 19 | #:use-module (ice-9 match) | |
20 | + | #:use-module (jsonld json) | |
20 | 21 | #:use-module (srfi srfi-9) | |
21 | 22 | #:export (make-active-context | |
22 | 23 | active-context? | |
… | |||
82 | 83 | (vocab #f) | |
83 | 84 | (language #f) | |
84 | 85 | (direction #f) | |
85 | - | (previous #nil)) | |
86 | + | (previous json-null)) | |
86 | 87 | (make-active-context definitions base original-base vocab language direction | |
87 | 88 | previous)) | |
88 | 89 |
jsonld/create-term-definition.scm
78 | 78 | (definition (new-term-definition #:protected? protected?))) | |
79 | 79 | (cond | |
80 | 80 | ;; 7 | |
81 | - | ((equal? value #nil) | |
82 | - | (set! value `(("@id" . #nil)))) | |
81 | + | ((json-null? value) | |
82 | + | (set! value `(("@id" . ,json-null)))) | |
83 | 83 | ;; 8 | |
84 | 84 | ((string? value) | |
85 | 85 | (set! value `(("@id" . ,value)))) | |
… | |||
150 | 150 | ;; 13.5 | |
151 | 151 | (when (json-has-key? value "@container") | |
152 | 152 | (let ((container (assoc-ref value "@container"))) | |
153 | - | (unless (member container '("@set" "@index" #nil)) | |
153 | + | (unless (member container `("@set" "@index" ,json-null)) | |
154 | 154 | (throw 'invalid-reverse-property)) | |
155 | 155 | (set! definition (update-term-definition definition | |
156 | 156 | #:container container)))) | |
… | |||
174 | 174 | ((and (json-has-key? value "@id") | |
175 | 175 | (not (equal? (assoc-ref value "@id") term))) | |
176 | 176 | ;; 14.1 | |
177 | - | (if (equal? (assoc-ref value "@id") #nil) | |
177 | + | (if (json-null? (assoc-ref value "@id")) | |
178 | 178 | (set! definition (update-term-definition definition | |
179 | - | #:iri #nil)) | |
179 | + | #:iri json-null)) | |
180 | 180 | ;; 14.2 | |
181 | 181 | (begin | |
182 | 182 | ;; 14.2.1 | |
… | |||
247 | 247 | active-context local-context prefix defined))) | |
248 | 248 | (set! defined (assoc-ref result "defined")) | |
249 | 249 | (set! active-context (assoc-ref result "active-context")))) | |
250 | - | (if (term-definition-ref active-context prefix) | |
250 | + | (if (not-null-or-false (term-definition-ref active-context prefix)) | |
251 | 251 | ;; 15.2 | |
252 | 252 | (set! definition (update-term-definition definition | |
253 | 253 | #:iri (string-append | |
… | |||
274 | 274 | (set! definition (update-term-definition | |
275 | 275 | definition #:iri "@type"))) | |
276 | 276 | ;; 18 | |
277 | - | ((active-context-vocab active-context) | |
277 | + | ((not-null-or-false (active-context-vocab active-context)) | |
278 | 278 | (set! definition (update-term-definition definition | |
279 | 279 | #:iri (string-append | |
280 | 280 | (active-context-vocab active-context) | |
… | |||
399 | 399 | (not (json-has-key? value "@type"))) | |
400 | 400 | ;; 22.1 | |
401 | 401 | (let ((language (assoc-ref value "@language"))) | |
402 | - | (unless (or (string? language) (equal? language #nil)) | |
402 | + | (unless (or (string? language) (json-null? language)) | |
403 | 403 | (throw 'invalid-language-mapping)) | |
404 | 404 | ;; a warning should be thrown if not bcp-47 compliant | |
405 | 405 | ;; 22.2 | |
… | |||
412 | 412 | (not (json-has-key? value "@type"))) | |
413 | 413 | ;; 23.1 | |
414 | 414 | (let ((direction (assoc-ref value "@direction"))) | |
415 | - | (unless (member direction '("ltr" "rtl" #nil)) | |
415 | + | (unless (member direction `("ltr" "rtl" ,json-null)) | |
416 | 416 | (throw 'invalid-base-direction)) | |
417 | 417 | ;; 23.2 | |
418 | 418 | (set! definition (update-term-definition definition | |
… | |||
460 | 460 | value)) | |
461 | 461 | (throw 'invalid-term-definition)) | |
462 | 462 | ;; 27 | |
463 | - | (unless (or override-protected? (not previous-definition) | |
463 | + | (unless (or override-protected? | |
464 | + | (not (not-null-or-false previous-definition)) | |
464 | 465 | (not (term-definition-protected? previous-definition))) | |
465 | 466 | ;; 27.1 | |
466 | 467 | (unless (term-definition-equal? |
jsonld/deserialize-jsonld.scm
54 | 54 | (define* (deserialize-jsonld generate-blank-node node-map dataset | |
55 | 55 | #:key produce-generalized-rdf? rdf-direction) | |
56 | 56 | ;; 1 | |
57 | + | (pk 'node-map node-map) | |
57 | 58 | (for-each-pair | |
58 | 59 | (lambda (graph-name graph) | |
59 | 60 | ;; 1.1 | |
… | |||
101 | 102 | rdf-direction item '())) | |
102 | 103 | (list-triples (assoc-ref res "list-triples")) | |
103 | 104 | (res (assoc-ref res "result"))) | |
104 | - | (unless (equal? res #nil) | |
105 | + | (unless (json-null? res) | |
105 | 106 | (set! triples | |
106 | 107 | (cons | |
107 | 108 | (make-rdf-triple subject property res) |
jsonld/download.scm
24 | 24 | #:use-module (web response) | |
25 | 25 | #:use-module (web uri) | |
26 | 26 | #:use-module (rnrs bytevectors) | |
27 | - | #:use-module (ice-9 match) | |
28 | 27 | #:use-module (srfi srfi-1) | |
29 | 28 | #:use-module (srfi srfi-9) | |
30 | 29 | #:use-module (sxml simple) |
jsonld/expansion.scm
35 | 35 | ;; 13.7.1 | |
36 | 36 | (set! expanded-value '()) | |
37 | 37 | ;; 13.7.3 | |
38 | - | (when (and (term-definition-ref active-context key)) | |
38 | + | (when (term-definition? (term-definition-ref active-context key)) | |
39 | 39 | (set! direction (term-definition-direction | |
40 | 40 | (term-definition-ref active-context key))) | |
41 | 41 | (when (equal? direction #f) | |
… | |||
51 | 51 | (for-each | |
52 | 52 | (lambda (item) | |
53 | 53 | ;; 13.7.4.2.1 | |
54 | - | (unless (equal? item #nil) | |
54 | + | (unless (json-null? item) | |
55 | 55 | ;; 13.7.4.2.2 | |
56 | 56 | (unless (string? item) | |
57 | 57 | (throw 'invalid-language-map-value)) | |
… | |||
61 | 61 | ;; TODO: if @language is not a bcp-47 one, we should issue a warning | |
62 | 62 | (when (equal? (expand-key active-context language) "@none") | |
63 | 63 | (set! v (alist-remove v "@language"))) | |
64 | - | (when direction | |
64 | + | (when (not-null-or-false direction) | |
65 | 65 | (set! v (alist-set v "@direction" direction))) | |
66 | 66 | (set! expanded-value | |
67 | 67 | (append expanded-value (list v)))))) | |
… | |||
80 | 80 | (set! expanded-value '()) | |
81 | 81 | ;; 13.8.2 | |
82 | 82 | (let ((index-key | |
83 | - | (if (term-definition-ref active-context key) | |
83 | + | (if (term-definition? (term-definition-ref active-context key)) | |
84 | 84 | (or (term-definition-index | |
85 | 85 | (term-definition-ref active-context key)) | |
86 | 86 | "@index") | |
87 | 87 | "@index")) | |
88 | - | ;; Should not be #nil, if it fails because of that, there's a weird corner case | |
89 | - | (map-context #nil) | |
90 | - | (expanded-index #nil)) | |
88 | + | ;; Should not be null, if it fails because of that, there's a weird corner case | |
89 | + | (map-context json-null) | |
90 | + | (expanded-index json-null)) | |
91 | 91 | ;; 13.8.3 | |
92 | 92 | (for-each-pair | |
93 | 93 | (lambda (index index-value) | |
94 | 94 | ;; 13.8.3.1 | |
95 | 95 | (when (or (member "@id" container-mapping) | |
96 | 96 | (member "@type" container-mapping)) | |
97 | - | (set! map-context (or (active-context-previous active-context) | |
98 | - | active-context))) | |
97 | + | (let ((previous (active-context-previous active-context))) | |
98 | + | (set! map-context (or (if (not-null-or-false previous) previous #f) | |
99 | + | active-context)))) | |
99 | 100 | ;; 13.8.3.2 | |
100 | 101 | (when (and (member "@type" container-mapping) | |
101 | - | (term-definition-ref map-context index) | |
102 | + | (term-definition? (term-definition-ref map-context index)) | |
102 | 103 | (not (equal? (term-definition-context | |
103 | 104 | (term-definition-ref map-context index)) | |
104 | 105 | #f))) | |
… | |||
110 | 111 | (term-definition-ref map-context index)) | |
111 | 112 | #:options options))) | |
112 | 113 | ;; 13.8.3.3 | |
113 | - | (when (equal? map-context #nil) | |
114 | + | (when (json-null? map-context) | |
114 | 115 | (set! map-context active-context)) | |
115 | 116 | ;; 13.8.3.4 | |
116 | 117 | (set! expanded-index (assoc-ref | |
… | |||
350 | 351 | ;; 13.4.7.2 | |
351 | 352 | (begin | |
352 | 353 | (unless (or (scalar? value) | |
353 | - | (equal? value #nil) | |
354 | + | (json-null? value) | |
354 | 355 | (and (jsonld-options-frame-expansion? options) | |
355 | 356 | (or (equal? value '()) | |
356 | 357 | (scalar-array? value)))) | |
… | |||
363 | 364 | (when (scalar? expanded-value) | |
364 | 365 | (set! expanded-value #(,expanded-value)))) | |
365 | 366 | ;; 13.4.7.4 | |
366 | - | (when (equal? expanded-value #nil) | |
367 | + | (when (json-null? expanded-value) | |
367 | 368 | (set! continue? #f) | |
368 | - | (set! result (alist-set result "@value" #nil)))) | |
369 | + | (set! result (alist-set result "@value" json-null)))) | |
369 | 370 | ;; 13.4.8 | |
370 | 371 | ((equal? expanded-property "@language") | |
371 | 372 | (unless (or (string? value) | |
… | |||
409 | 410 | (throw 'invalid-@index-value))) | |
410 | 411 | ;; 13.4.11 | |
411 | 412 | ((equal? expanded-property "@list") | |
412 | - | (if (or (equal? active-property "@graph") (equal? active-property #nil)) | |
413 | + | (if (or (equal? active-property "@graph") (json-null? active-property)) | |
413 | 414 | ;; 13.4.11.1 | |
414 | 415 | (set! continue? #f) | |
415 | 416 | (begin | |
… | |||
496 | 497 | #:options options)))) | |
497 | 498 | ;; 13.4.16 | |
498 | 499 | (unless (or (not continue?) | |
499 | - | (and (equal? expanded-value #nil) | |
500 | + | (and (json-null? expanded-value) | |
500 | 501 | (equal? expanded-property "@value") | |
501 | 502 | (equal? input-type "@json"))) | |
502 | 503 | (set! result (alist-set result expanded-property expanded-value))) | |
… | |||
514 | 515 | #:vocab? #t | |
515 | 516 | #:options options) | |
516 | 517 | "iri")) | |
517 | - | (expanded-value #nil) | |
518 | + | (expanded-value json-null) | |
518 | 519 | ;; whether we continue evaluating this key or not. #f means go | |
519 | 520 | ;; immediately to processing the next key-value pair. | |
520 | 521 | (continue? #t) | |
521 | 522 | (container-mapping #f)) | |
522 | 523 | (cond | |
523 | 524 | ;; 13.3 | |
524 | - | ((or (equal? expanded-property #nil) | |
525 | + | ((or (json-null? expanded-property) | |
525 | 526 | (not (or (json-keyword? expanded-property) | |
526 | 527 | (string-index expanded-property #\:)))) | |
527 | 528 | (set! continue? #f)) | |
… | |||
541 | 542 | (let* ((def (term-definition-ref active-context key)) | |
542 | 543 | (container (and (term-definition? def) | |
543 | 544 | (term-definition-container def)))) | |
544 | - | (and def | |
545 | + | (and (term-definition? def) | |
545 | 546 | (if (json-array? container) | |
546 | 547 | (array->list container) | |
547 | 548 | (if container (list container) '()))))) | |
548 | 549 | (cond | |
549 | 550 | ;; 13.6 | |
550 | 551 | ((and | |
551 | - | (term-definition-ref active-context key) | |
552 | + | (term-definition? (term-definition-ref active-context key)) | |
552 | 553 | (equal? | |
553 | 554 | (term-definition-type | |
554 | 555 | (term-definition-ref active-context key)) | |
… | |||
582 | 583 | #:options options)))))) | |
583 | 584 | ;; 13.10 and previous (via continue?): do we process further, or | |
584 | 585 | ;; go to the next key immediately? | |
585 | - | (when (and continue? (not (equal? expanded-value #nil))) | |
586 | + | (when (and continue? (not (json-null? expanded-value))) | |
586 | 587 | ;; 13.11 | |
587 | 588 | (when (and container-mapping | |
588 | 589 | (member "@list" container-mapping) | |
… | |||
606 | 607 | expanded-value)) | |
607 | 608 | (set! expanded-value (list->array 1 expanded-value))) | |
608 | 609 | ;; 13.13 | |
609 | - | (if (and (term-definition-ref active-context key) | |
610 | + | (if (and (term-definition? | |
611 | + | (term-definition-ref active-context key)) | |
610 | 612 | (term-definition-reverse? | |
611 | 613 | (term-definition-ref active-context key))) | |
612 | 614 | ;; 13.13.1 and 13.13.2 | |
… | |||
705 | 707 | See @url{https://www.w3.org/TR/2014/REC-json-ld-api-20140116}." | |
706 | 708 | ;; 3 | |
707 | 709 | (define property-scoped-context | |
708 | - | (if (term-definition-ref active-context active-property) | |
709 | - | ;; can be #nil, so we cannot use `or` here | |
710 | + | (if (term-definition? (term-definition-ref active-context active-property)) | |
711 | + | ;; can be null, so we cannot use `or` here | |
710 | 712 | (term-definition-context (term-definition-ref | |
711 | 713 | active-context active-property)) | |
712 | 714 | #f)) | |
… | |||
715 | 717 | (set! options (update-jsonld-options options #:frame-expansion? #f))) | |
716 | 718 | (cond | |
717 | 719 | ;; 1 | |
718 | - | ((equal? element #nil) #nil) | |
720 | + | ((json-null? element) json-null) | |
719 | 721 | ;; 4 | |
720 | 722 | ((scalar? element) | |
721 | - | (if (member active-property '(#nil "@graph")) | |
723 | + | (if (member active-property `(,json-null "@graph")) | |
722 | 724 | ;; 4.1 | |
723 | - | #nil | |
725 | + | json-null | |
724 | 726 | (begin | |
725 | 727 | ;; 4.2 | |
726 | 728 | (unless (equal? property-scoped-context #f) | |
… | |||
741 | 743 | #:options options))) | |
742 | 744 | ;; 5.2.2 | |
743 | 745 | (when (and | |
744 | - | (term-definition-ref active-context active-property) | |
746 | + | (term-definition? (term-definition-ref active-context active-property)) | |
745 | 747 | (term-definition-container (term-definition-ref active-context active-property)) | |
746 | 748 | (member "@list" (array->list (term-definition-container (term-definition-ref active-context active-property)))) | |
747 | 749 | (json-array? expanded-item)) | |
… | |||
749 | 751 | ;; 5.2.3 | |
750 | 752 | (if (json-array? expanded-item) | |
751 | 753 | (set! result (append result (array->list expanded-item))) | |
752 | - | (unless (equal? expanded-item #nil) | |
754 | + | (unless (json-null? expanded-item) | |
753 | 755 | (set! result (append result (list expanded-item))))))) | |
754 | 756 | (array->list element)) | |
755 | 757 | ;; 5.3 | |
… | |||
757 | 759 | ;; 6 | |
758 | 760 | (else | |
759 | 761 | ;; 7 | |
760 | - | (when (active-context-previous active-context) | |
762 | + | (unless (json-null? (active-context-previous active-context)) | |
761 | 763 | (let ((previous (active-context-previous active-context))) | |
762 | 764 | (unless (or from-map? (json-key-expanded-to? active-context element "@value") | |
763 | 765 | (and | |
… | |||
784 | 786 | (let ((type-scoped-context active-context) | |
785 | 787 | (result '()) | |
786 | 788 | (nests '()) | |
787 | - | (input-type #nil) | |
789 | + | (input-type json-null) | |
788 | 790 | (found-first-entry? #f)) | |
789 | 791 | ;; 11 | |
790 | 792 | (for-each-pair | |
… | |||
793 | 795 | ;; 12 | |
794 | 796 | (unless found-first-entry? | |
795 | 797 | (match value | |
796 | - | ((json-array? value) | |
798 | + | ((? json-array? value) | |
797 | 799 | (set! input-type (car (reverse (array->list value))))) | |
798 | 800 | (_ (set! input-type value))) | |
799 | 801 | (set! input-type | |
… | |||
807 | 809 | ;; 11.2 | |
808 | 810 | (for-each | |
809 | 811 | (lambda (term) | |
810 | - | (when (and (term-definition-ref type-scoped-context term) | |
812 | + | (when (and (term-definition? (term-definition-ref type-scoped-context term)) | |
811 | 813 | (not (equal? | |
812 | 814 | (term-definition-context | |
813 | 815 | (term-definition-ref type-scoped-context term)) | |
… | |||
859 | 861 | ;; 15.2 | |
860 | 862 | (unless (equal? (assoc-ref result "@type") "@json") | |
861 | 863 | ;; 15.3 | |
862 | - | (when (equal? (assoc-ref result "@value") #nil) | |
863 | - | (set! result #nil)) | |
864 | + | (when (json-null? (assoc-ref result "@value")) | |
865 | + | (set! result json-null)) | |
864 | 866 | ;; 15.4 | |
865 | 867 | (unless (or | |
866 | 868 | (string? (assoc-ref result "@value")) | |
… | |||
903 | 905 | ((and (json-has-key? result "@language") | |
904 | 906 | (null? (filter (lambda (p) (not (equal? (car p) "@language"))) | |
905 | 907 | result))) | |
906 | - | (set! result #nil)) | |
908 | + | (set! result json-null)) | |
907 | 909 | ;; 19 | |
908 | - | ((or (equal? active-property #nil) (equal? active-property "@graph")) | |
910 | + | ((or (json-null? active-property) (equal? active-property "@graph")) | |
909 | 911 | (if (or (equal? result '()) | |
910 | 912 | (json-has-key? result "@value") | |
911 | 913 | (json-has-key? result "@list")) | |
912 | - | (set! result #nil) | |
914 | + | (set! result json-null) | |
913 | 915 | (when (and | |
914 | 916 | (not (jsonld-options-frame-expansion? options)) | |
915 | 917 | (json-has-key? result "@id") | |
916 | 918 | (null? (filter (lambda (p) (not (equal? (car p) "@id"))) | |
917 | 919 | result))) | |
918 | - | (set! result #nil)))) | |
920 | + | (set! result json-null)))) | |
919 | 921 | ;; 20 | |
920 | 922 | (else #t)) | |
921 | 923 | result)))) |
jsonld/generate-blank-node-identifier.scm
25 | 25 | ||
26 | 26 | (define* (generate-blank-node-identifier identifier) | |
27 | 27 | ;; 1 | |
28 | - | (if (and (not (equal? identifier #nil)) | |
28 | + | (if (and (not (json-null? identifier)) | |
29 | 29 | (json-has-key? identifier-map identifier)) | |
30 | 30 | (assoc-ref identifier-map identifier) | |
31 | 31 | (let ((blank-node-identifier | |
32 | 32 | (string-append "_:b" (number->string counter)))) | |
33 | 33 | (set! counter (+ counter 1)) | |
34 | - | (unless (equal? identifier #nil) | |
34 | + | (unless (json-null? identifier) | |
35 | 35 | (set! identifier-map | |
36 | 36 | (alist-set identifier-map identifier blank-node-identifier))) | |
37 | 37 | blank-node-identifier))) |
jsonld/inverse-context-creation.scm
36 | 36 | (let ((result '()) | |
37 | 37 | (default-language "@none")) | |
38 | 38 | ;; 2 | |
39 | - | (when (active-context-language active-context) | |
39 | + | (when (not-null-or-false (active-context-language active-context)) | |
40 | 40 | (set! default-language (string-downcase (active-context-language | |
41 | 41 | active-context)))) | |
42 | 42 | ;; 3 | |
43 | 43 | (for-each-pair | |
44 | 44 | (lambda (term term-definition) | |
45 | 45 | ;; 3.1 | |
46 | - | (unless (equal? term-definition #nil) | |
46 | + | (unless (json-null? term-definition) | |
47 | 47 | ;; 3.2 | |
48 | 48 | (let ((container "@none") | |
49 | 49 | ;; 3.3 | |
… | |||
134 | 134 | ;; 3.14 | |
135 | 135 | ((not (equal? (term-definition-language term-definition) #f)) | |
136 | 136 | (let ((language | |
137 | - | (if (term-definition-language term-definition) | |
137 | + | (if (not-null-or-false (term-definition-language term-definition)) | |
138 | 138 | (string-downcase | |
139 | 139 | (term-definition-language term-definition)) | |
140 | 140 | "@null"))) | |
… | |||
144 | 144 | ;; 3.15 | |
145 | 145 | ((not (equal? (term-definition-direction term-definition) #f)) | |
146 | 146 | (let ((direction | |
147 | - | (if (term-definition-direction term-definition) | |
147 | + | (if (not-null-or-false (term-definition-direction term-definition)) | |
148 | 148 | (string-append | |
149 | 149 | "_" | |
150 | 150 | (string-downcase | |
… | |||
159 | 159 | (string-downcase | |
160 | 160 | (string-append | |
161 | 161 | default-language "_" | |
162 | - | (or (active-context-direction active-context) | |
162 | + | (or (not-null-or-false (active-context-direction active-context)) | |
163 | 163 | ""))))) | |
164 | 164 | (unless (json-has-key? language-map lang-dir) | |
165 | 165 | (set! language-map |
jsonld/iri-compaction.scm
34 | 34 | ;; in that case we iri-compact each part of it and return an array. | |
35 | 35 | (cond | |
36 | 36 | ;; 2 | |
37 | - | ((equal? var #nil) | |
38 | - | #nil) | |
37 | + | ((json-null? var) json-null) | |
39 | 38 | ((json-array? var) | |
40 | 39 | (list->array 1 | |
41 | 40 | (map | |
… | |||
49 | 48 | (else | |
50 | 49 | (begin | |
51 | 50 | (let ((result #f)) | |
51 | + | (pk 'inverse (assoc-ref inverse-context var)) | |
52 | 52 | ;; 2 | |
53 | 53 | (when (and vocab? (json-has-key? inverse-context var)) | |
54 | 54 | (let ((default-language | |
55 | 55 | ;; 2.1 | |
56 | - | (if (or (active-context-direction active-context) | |
57 | - | (active-context-language active-context)) | |
56 | + | (if (or (not-null-or-false (active-context-direction active-context)) | |
57 | + | (not-null-or-false (active-context-language active-context))) | |
58 | 58 | (string-append | |
59 | - | (or (active-context-language active-context) "") | |
59 | + | (or (not-null-or-false (active-context-language active-context)) | |
60 | + | "") | |
60 | 61 | "_" | |
61 | - | (or (active-context-direction active-context) "")) | |
62 | + | (or (not-null-or-false (active-context-direction active-context)) | |
63 | + | "")) | |
62 | 64 | "@none")) | |
63 | 65 | ;; 2.3 | |
64 | 66 | (containers '()) | |
… | |||
89 | 91 | ;; 2.7.2 | |
90 | 92 | (let ((lst (array->list (assoc-ref value "@list"))) | |
91 | 93 | ;; 2.7.3 | |
92 | - | (common-type #nil) | |
93 | - | (common-language #nil)) | |
94 | + | (common-type json-null) | |
95 | + | (common-language json-null)) | |
94 | 96 | (when (null? lst) | |
95 | 97 | (set! common-language default-language)) | |
96 | 98 | ;; 2.7.4 | |
… | |||
117 | 119 | ;; 2.7.4.3 | |
118 | 120 | (set! item-type "@id")) | |
119 | 121 | ;; 2.7.4.4 | |
120 | - | (if (equal? common-language #nil) | |
122 | + | (if (json-null? common-language) | |
121 | 123 | (set! common-language item-language) | |
122 | 124 | (unless (or (equal? common-language item-language) | |
123 | 125 | (not (json-has-key? item "@value"))) | |
124 | 126 | (set! common-language "@none"))) | |
125 | 127 | ;; 2.7.4.6 | |
126 | - | (if (equal? common-type #nil) | |
128 | + | (if (json-null? common-type) | |
127 | 129 | (set! common-type item-type) | |
128 | 130 | (unless (equal? common-type item-type) | |
129 | 131 | (set! common-type "@none"))))) | |
130 | 132 | lst) | |
131 | 133 | ;; 2.7.5 | |
132 | - | (when (equal? common-language #nil) | |
134 | + | (when (json-null? common-language) | |
133 | 135 | (set! common-language "@none")) | |
134 | - | (when (equal? common-type #nil) | |
136 | + | (when (json-null? common-type) | |
135 | 137 | (set! common-type "@none")) | |
136 | 138 | (if (not (equal? common-type "@none")) | |
137 | 139 | (begin | |
… | |||
204 | 206 | value))) | |
205 | 207 | (set! containers (append containers '("@language" "@language@set"))))) | |
206 | 208 | ;; 2.13 | |
207 | - | (when (equal? type/language-value #nil) | |
209 | + | (when (equal? type/language-value json-null) | |
208 | 210 | (set! type/language-value "@null")) | |
209 | 211 | ;; 2.15 | |
210 | 212 | (when (equal? type/language-value "@reverse") | |
… | |||
218 | 220 | #:vocab? #t | |
219 | 221 | #:processing-mode processing-mode)) | |
220 | 222 | (def (term-definition-ref active-context compacted-iri)) | |
221 | - | (iri (if def (term-definition-iri def) #f))) | |
223 | + | (iri (if (term-definition? def) | |
224 | + | (term-definition-iri def) | |
225 | + | #f))) | |
222 | 226 | (if (equal? iri (assoc-ref value "@id")) | |
223 | 227 | (set! preferred-values | |
224 | 228 | (append preferred-values '("@vocab" "@id" "@none"))) | |
… | |||
238 | 242 | (string-index s #\_)) | |
239 | 243 | preferred-values)) | |
240 | 244 | (underscore (if (null? underscore-vals) #f (car underscore-vals)))) | |
241 | - | (when underscore | |
245 | + | (when (not-null-or-false underscore) | |
242 | 246 | (set! preferred-values | |
243 | 247 | (append | |
244 | 248 | preferred-values | |
… | |||
247 | 251 | (cons "" (cdr (string-split underscore #\_))) "_")))))) | |
248 | 252 | ;; 2.20 | |
249 | 253 | (let ((term (term-selection inverse-context var containers type/language preferred-values))) | |
250 | - | (when term | |
254 | + | (when (not-null-or-false term) | |
251 | 255 | (set-cond! result term))))) | |
252 | 256 | ;; 3 | |
253 | - | (when (and vocab? (active-context-vocab active-context)) | |
257 | + | (when (and vocab? (not-null-or-false (active-context-vocab active-context))) | |
254 | 258 | (let ((vocab (active-context-vocab active-context))) | |
259 | + | (pk 'vocab vocab var) | |
255 | 260 | (when (and (>= (string-length var) (string-length vocab)) | |
256 | 261 | (equal? (substring var 0 (string-length vocab)) vocab)) | |
257 | 262 | (let ((suffix (substring var (string-length vocab)))) | |
258 | - | (unless (term-definition-ref active-context suffix) | |
263 | + | (when (not (not-null-or-false (term-definition-ref active-context suffix))) | |
259 | 264 | (set-cond! result suffix)))))) | |
260 | 265 | ;; 4 | |
261 | - | (let ((compact-iri #nil)) | |
266 | + | (let ((compact-iri json-null)) | |
262 | 267 | ;; 5 | |
263 | 268 | (for-each-pair | |
264 | 269 | (lambda (term def) | |
265 | 270 | ;; 5.1 | |
266 | - | (unless (or (equal? (term-definition-iri def) #nil) | |
271 | + | (unless (or (json-null? (term-definition-iri def)) | |
267 | 272 | (equal? (term-definition-iri def) var) | |
268 | 273 | (not (string? var)) | |
269 | 274 | (< (string-length var) (string-length (term-definition-iri def))) | |
… | |||
280 | 285 | (string-length | |
281 | 286 | (term-definition-iri def)))))) | |
282 | 287 | ;; 5.3 | |
283 | - | (when (or (equal? compact-iri #nil) | |
288 | + | (when (or (json-null? compact-iri) | |
284 | 289 | (< (string-length candidate) (string-length compact-iri)) | |
285 | 290 | (and (= (string-length candidate) | |
286 | 291 | (string-length compact-iri)) | |
287 | 292 | (string<=? candidate compact-iri))) | |
288 | 293 | (let ((def (term-definition-ref active-context candidate))) | |
289 | - | (when (or (not def) | |
290 | - | (and (not value) | |
294 | + | (when (or (not (term-definition? def)) | |
295 | + | (and (not (not-null-or-false value)) | |
291 | 296 | (equal? (term-definition-iri def) var))) | |
292 | 297 | (set! compact-iri candidate))))))) | |
293 | 298 | (active-context-definitions active-context)) | |
294 | 299 | ;; 6 | |
295 | - | (when compact-iri | |
300 | + | (when (not-null-or-false compact-iri) | |
296 | 301 | (set-cond! result compact-iri))) | |
297 | 302 | ;; 7 | |
298 | 303 | (unless result | |
… | |||
310 | 315 | (throw 'iri-confused-with-prefix))))) | |
311 | 316 | ;; 8 | |
312 | 317 | (unless vocab? | |
313 | - | (when (and (active-context-base active-context) (absolute-iri? var)) | |
318 | + | (when (and (not-null-or-false (active-context-base active-context)) | |
319 | + | (absolute-iri? var)) | |
314 | 320 | (set-cond! result | |
315 | 321 | (make-relative-iri var (active-context-base active-context))))) | |
316 | 322 | ;; 9 |
jsonld/iri-expansion.scm
55 | 55 | ;; 2 | |
56 | 56 | (when (and (keyword-form? iri) (not (json-keyword? iri))) | |
57 | 57 | ;; Should give a warning and return null, we only return null without warning | |
58 | - | (set! iri #nil)) | |
58 | + | (set! iri json-null)) | |
59 | 59 | ;; if not 1 or 2 | |
60 | - | (unless (or (json-keyword? iri) (equal? iri #nil)) | |
60 | + | (unless (or (json-keyword? iri) (json-null? iri)) | |
61 | 61 | ;; 3 | |
62 | 62 | (when (and local-context (json-has-key? local-context iri)) | |
63 | 63 | (let ((def (assoc-ref defined iri))) | |
… | |||
101 | 101 | ;; 6.4 | |
102 | 102 | (if (and | |
103 | 103 | (term-definition? (term-definition-ref active-context prefix)) | |
104 | - | (term-definition-iri (term-definition-ref active-context prefix)) | |
104 | + | (not-null-or-false (term-definition-iri (term-definition-ref active-context prefix))) | |
105 | 105 | (term-definition-prefix? (term-definition-ref active-context prefix))) | |
106 | 106 | (set! iri | |
107 | 107 | (string-append (term-definition-iri | |
… | |||
112 | 112 | ((absolute-iri? iri) | |
113 | 113 | (set! iri iri)) | |
114 | 114 | ;; 7 | |
115 | - | ((and vocab? (active-context-vocab active-context)) | |
116 | - | (set! iri (string-append (active-context-vocab active-context) | |
115 | + | ((and vocab? (not-null-or-false (active-context-vocab active-context))) | |
116 | + | (set! iri (string-append (not-null-or-false (active-context-vocab active-context)) | |
117 | 117 | iri))) | |
118 | 118 | (else | |
119 | - | (if (and document-relative? (not (equal? (active-context-base active-context) #nil))) | |
119 | + | (if (and document-relative? (not-null-or-false (active-context-base active-context))) | |
120 | 120 | ;; 8 | |
121 | 121 | (set! iri (resolve-iri (or | |
122 | 122 | (active-context-base active-context) | |
… | |||
125 | 125 | ;; 9 | |
126 | 126 | (set! iri iri))))))))) | |
127 | 127 | ;; 7 | |
128 | - | ((and vocab? (active-context-vocab active-context)) | |
128 | + | ((and vocab? (not-null-or-false (active-context-vocab active-context))) | |
129 | 129 | (set! iri (string-append (active-context-vocab active-context) | |
130 | 130 | iri))) | |
131 | 131 | (else | |
132 | - | (if (and document-relative? (not (equal? (active-context-base active-context) #nil))) | |
132 | + | (if (and document-relative? (not-null-or-false (active-context-base active-context))) | |
133 | 133 | ;; 8 | |
134 | 134 | (set! iri (resolve-iri (or | |
135 | 135 | (active-context-base active-context) |
jsonld/json.scm
39 | 39 | json-array? | |
40 | 40 | json-has-key? | |
41 | 41 | json-keyword? | |
42 | + | json-null | |
43 | + | json-null? | |
42 | 44 | json-object? | |
43 | 45 | jsonld-error->string | |
44 | 46 | keyword-form? | |
… | |||
46 | 48 | make-jsonld-options | |
47 | 49 | merge-json | |
48 | 50 | node-object? | |
51 | + | not-null-or-false | |
49 | 52 | processing-mode-1.0? | |
50 | 53 | relative-iri? | |
51 | 54 | same-json? | |
… | |||
120 | 123 | "Whether a value is a Json array." | |
121 | 124 | (and (array? v) (not (string? v)))) | |
122 | 125 | ||
126 | + | (define (json-null? v) | |
127 | + | (equal? v 'null)) | |
128 | + | ||
129 | + | (define json-null 'null) | |
130 | + | ||
123 | 131 | (define (json-object? v) | |
124 | 132 | "Whether a value is a Json object." | |
125 | - | (and (list? v) (not (equal? v #nil)))) | |
133 | + | (and (list? v) (not (json-null? v)))) | |
134 | + | ||
135 | + | (define (not-null-or-false v) | |
136 | + | (and (not (json-null? v)) v)) | |
126 | 137 | ||
127 | 138 | (define (json-has-key? obj key) | |
128 | 139 | "Whether a Json object @var{obj} has a @var{key}." |
jsonld/list-to-rdf.scm
24 | 24 | #:export (list-to-rdf)) | |
25 | 25 | ||
26 | 26 | (define* (list-to-rdf generate-blank-node rdf-direction lst list-triples) | |
27 | - | (let ((result #nil)) | |
27 | + | (let ((result json-null)) | |
28 | 28 | (if (null? lst) | |
29 | 29 | ;; 1 | |
30 | 30 | (set! result (rdf-iri "nil")) | |
31 | 31 | ;; 2 | |
32 | 32 | (let ((bnodes (map | |
33 | 33 | (lambda _ | |
34 | - | (blank-node->rdf-blank-node (generate-blank-node #nil))) | |
34 | + | (blank-node->rdf-blank-node (generate-blank-node json-null))) | |
35 | 35 | lst))) | |
36 | 36 | ;; 3 | |
37 | 37 | (let loop ((bnodes bnodes) (lst lst)) | |
… | |||
46 | 46 | (object (assoc-ref res "result")) | |
47 | 47 | (embedded-triples (assoc-ref res "list-triples"))) | |
48 | 48 | ;; 3.3 | |
49 | - | (unless (equal? object #nil) | |
49 | + | (unless (json-null? object) | |
50 | 50 | (set! list-triples | |
51 | 51 | (cons (make-rdf-triple subject (rdf-iri "first") object) | |
52 | 52 | list-triples))) |
jsonld/node-map-generation.scm
68 | 68 | (define (get-node-map-generation generate-blank-node) | |
69 | 69 | (define* (node-map-generation element node-map | |
70 | 70 | #:key (active-graph "@default") | |
71 | - | (active-subject #nil) | |
72 | - | (active-property #nil) | |
73 | - | (lst #nil)) | |
71 | + | (active-subject json-null) | |
72 | + | (active-property json-null) | |
73 | + | (lst json-null)) | |
74 | 74 | ;; 1 | |
75 | 75 | (if (json-array? element) | |
76 | 76 | (for-each | |
… | |||
84 | 84 | (set! lst (assoc-ref res "list")))) | |
85 | 85 | (array->list element)) | |
86 | 86 | ;; 2: otherwise | |
87 | - | (let* ((graph (or (assoc-ref node-map active-graph) '())) | |
88 | - | (subject-node (if (equal? active-subject #nil) | |
87 | + | (let* ((graph (or (not-null-or-false (assoc-ref node-map active-graph)) | |
88 | + | '())) | |
89 | + | (subject-node (if (json-null? active-subject) | |
89 | 90 | '() | |
90 | - | (or (assoc-ref graph active-subject) '()))) | |
91 | + | (or (not-null-or-false (assoc-ref graph active-subject)) | |
92 | + | '()))) | |
91 | 93 | (types (assoc-ref element "@type")) | |
92 | 94 | (types (if (json-array? types) | |
93 | 95 | (array->list types) | |
94 | - | (if types (list types) '()))) | |
96 | + | (if (not-null-or-false types) (list types) '()))) | |
95 | 97 | ;; 3 | |
96 | 98 | (types | |
97 | 99 | (map | |
… | |||
106 | 108 | (set! element (alist-set element "@type" (car types))))) | |
107 | 109 | ;; 4 | |
108 | 110 | (when (json-has-key? element "@value") | |
109 | - | (if (equal? lst #nil) | |
111 | + | (if (json-null? lst) | |
110 | 112 | (begin | |
111 | 113 | ;; 4.1.1 | |
112 | 114 | (unless (json-has-key? subject-node active-property) | |
… | |||
132 | 134 | (set! result (assoc-ref res "list")) | |
133 | 135 | (set! node-map (assoc-ref res "node-map")) | |
134 | 136 | (set! graph (assoc-ref node-map active-graph)) | |
135 | - | (set! subject-node (or (assoc-ref graph active-subject) '())) | |
136 | - | (if (equal? lst #nil) | |
137 | + | (set! subject-node (or (not-null-or-false (assoc-ref graph active-subject)) | |
138 | + | '())) | |
139 | + | (if (json-null? lst) | |
137 | 140 | ;; 5.3 | |
138 | 141 | (begin | |
139 | 142 | (set! subject-node | |
… | |||
155 | 158 | (if (blank-node? (assoc-ref element "@id")) | |
156 | 159 | (generate-blank-node (assoc-ref element "@id")) | |
157 | 160 | (assoc-ref element "@id")) | |
158 | - | (generate-blank-node #nil)))) | |
161 | + | (generate-blank-node json-null)))) | |
159 | 162 | ;; 6.3 | |
160 | - | (unless (or (json-has-key? graph id) (not id)) | |
163 | + | (unless (or (json-has-key? graph id) (not (not-null-or-false id))) | |
161 | 164 | (set! graph | |
162 | 165 | (alist-set graph id `(("@id" . ,id)))) | |
163 | 166 | (set! node-map (alist-set node-map active-graph graph))) | |
164 | 167 | ;; 6.4 | |
165 | - | (let ((node (or (assoc-ref graph id) '()))) | |
168 | + | (let ((node (or (not-null-or-false (assoc-ref graph id)) '()))) | |
166 | 169 | (cond | |
167 | 170 | ;; 6.5 | |
168 | 171 | ((json-object? active-subject) | |
… | |||
173 | 176 | ;; 6.5.1 | |
174 | 177 | (set! node | |
175 | 178 | (alist-set node active-property `#(,active-subject)))) | |
176 | - | (when id | |
179 | + | (when (not-null-or-false id) | |
177 | 180 | (set! graph (alist-set graph id node))) | |
178 | 181 | (set! node-map (alist-set node-map active-graph graph))) | |
179 | 182 | ;; 6.6 | |
180 | - | ((not (equal? active-property #nil)) | |
183 | + | ((not (json-null? active-property)) | |
181 | 184 | ;; 6.6.1 | |
182 | 185 | (let ((reference `(("@id" . ,id)))) | |
183 | - | (if (equal? lst #nil) | |
186 | + | (if (json-null? lst) | |
184 | 187 | ;; 6.6.2 | |
185 | 188 | (begin | |
186 | 189 | (if (json-has-key? subject-node active-property) | |
… | |||
201 | 204 | (when (json-has-key? element "@type") | |
202 | 205 | (set! node | |
203 | 206 | (append-if-not-in node "@type" (assoc-ref element "@type"))) | |
204 | - | (when id | |
207 | + | (when (not-null-or-false id) | |
205 | 208 | (set! graph (alist-set graph id node))) | |
206 | 209 | (set! node-map (alist-set node-map active-graph graph))) | |
207 | 210 | ;; 6.8 | |
… | |||
233 | 236 | #:active-property property))) | |
234 | 237 | (set! node-map (assoc-ref res "node-map")) | |
235 | 238 | (set! graph (assoc-ref node-map active-graph)) | |
236 | - | (set! subject-node (or (assoc-ref graph active-subject) | |
239 | + | (set! subject-node (or (not-null-or-false | |
240 | + | (assoc-ref graph active-subject)) | |
237 | 241 | '())) | |
238 | - | (when id | |
242 | + | (when (not-null-or-false id) | |
239 | 243 | (set! node (assoc-ref graph id))))) | |
240 | 244 | (array->list values))) | |
241 | 245 | reverse-map) | |
… | |||
249 | 253 | #:active-graph id))) | |
250 | 254 | (set! node-map (assoc-ref res "node-map")) | |
251 | 255 | (set! graph (assoc-ref node-map active-graph)) | |
252 | - | (set! subject-node (or (assoc-ref graph active-subject) '())) | |
253 | - | (when id | |
256 | + | (set! subject-node (or (not-null-or-false | |
257 | + | (assoc-ref graph active-subject)) | |
258 | + | '())) | |
259 | + | (when (not-null-or-false id) | |
254 | 260 | (set! node (assoc-ref graph id)))) | |
255 | 261 | (set! element (alist-remove element "@graph"))) | |
256 | 262 | ;; 6.11 | |
… | |||
261 | 267 | #:active-graph active-graph))) | |
262 | 268 | (set! node-map (assoc-ref res "node-map")) | |
263 | 269 | (set! graph (assoc-ref node-map active-graph)) | |
264 | - | (set! subject-node (or (assoc-ref graph active-subject) '())) | |
265 | - | (when id | |
270 | + | (set! subject-node (or (not-null-or-false | |
271 | + | (assoc-ref graph active-subject)) | |
272 | + | '())) | |
273 | + | (when (not-null-or-false id) | |
266 | 274 | (set! node (assoc-ref graph id)))) | |
267 | 275 | (set! element (alist-remove element "@included"))) | |
268 | 276 | ;; 6.12 | |
… | |||
274 | 282 | ;; 6.12.2 | |
275 | 283 | (unless (json-has-key? node property) | |
276 | 284 | (set! node (alist-set node property #())) | |
277 | - | (when id | |
285 | + | (when (not-null-or-false id) | |
278 | 286 | (set! graph (alist-set graph id node))) | |
279 | 287 | (set! node-map (alist-set node-map active-graph graph))) | |
280 | 288 | ;; 6.12.3 | |
… | |||
284 | 292 | #:active-property property))) | |
285 | 293 | (set! node-map (assoc-ref res "node-map")) | |
286 | 294 | (set! graph (assoc-ref node-map active-graph)) | |
287 | - | (set! subject-node (or (assoc-ref graph active-subject) '())) | |
288 | - | (when id | |
295 | + | (set! subject-node (or (not-null-or-false | |
296 | + | (assoc-ref graph active-subject)) | |
297 | + | '())) | |
298 | + | (when (not-null-or-false id) | |
289 | 299 | (set! node (assoc-ref graph id))))) | |
290 | 300 | (alist-sort-by-key element)) | |
291 | - | (when id | |
301 | + | (when (not-null-or-false id) | |
292 | 302 | (set! graph (alist-set graph id node)))))) | |
293 | 303 | (when (string? active-subject) | |
294 | 304 | (set! graph (alist-set graph active-subject subject-node))) |
jsonld/object-to-rdf.scm
37 | 37 | ||
38 | 38 | (define (canonical-json value) | |
39 | 39 | (cond | |
40 | - | ((member value '(#t #f #nil)) | |
40 | + | ((member value `(#t #f ,json-null)) | |
41 | 41 | value) | |
42 | 42 | ((string? value) value) | |
43 | 43 | ((number? value) | |
… | |||
70 | 70 | #f))) | |
71 | 71 | ||
72 | 72 | (define* (object-to-rdf generate-blank-node rdf-direction item list-triples) | |
73 | - | (let ((result #nil)) | |
73 | + | (let ((result json-null)) | |
74 | 74 | (cond | |
75 | 75 | ;; 1 | |
76 | 76 | ((and (node-object? item) (not (well-formed? (assoc-ref item "@id")))) | |
77 | - | (set! result #nil)) | |
77 | + | (set! result json-null)) | |
78 | 78 | ;; 2 | |
79 | 79 | ((node-object? item) | |
80 | 80 | (set! result (assoc-ref item "@id"))) | |
… | |||
90 | 90 | (else | |
91 | 91 | ;; 4 | |
92 | 92 | (let ((value (assoc-ref item "@value")) | |
93 | - | (datatype (or (assoc-ref item "@type") #nil))) | |
93 | + | (datatype (or (assoc-ref item "@type") json-null))) | |
94 | 94 | (cond | |
95 | 95 | ;; 6 | |
96 | - | ((and (not (equal? datatype #nil)) (not (equal? datatype "@json")) | |
96 | + | ((and (not (json-null? datatype)) (not (equal? datatype "@json")) | |
97 | 97 | (not (well-formed? datatype))) | |
98 | - | (set! result #nil)) | |
98 | + | (set! result json-null)) | |
99 | 99 | ;; 7 | |
100 | 100 | ((and | |
101 | 101 | (json-has-key? item "@language") | |
102 | 102 | (not (well-formed-language-tag? (assoc-ref item "@language")))) | |
103 | - | (set! result #nil)) | |
103 | + | (set! result json-null)) | |
104 | 104 | (else | |
105 | 105 | ;; 8 | |
106 | 106 | (when (equal? datatype "@json") | |
… | |||
109 | 109 | (cond | |
110 | 110 | ;; 9 | |
111 | 111 | ((boolean? value) | |
112 | - | (when (equal? datatype #nil) | |
112 | + | (when (json-null? datatype) | |
113 | 113 | (set! datatype (xsd-iri "boolean"))) | |
114 | 114 | (set! value (if value "true" "false"))) | |
115 | 115 | ;; 10 | |
… | |||
117 | 117 | (or (not (integer? (inexact->exact value))) | |
118 | 118 | (>= (abs value) (expt 10 21)) | |
119 | 119 | (equal? datatype (xsd-iri "double")))) | |
120 | - | (when (equal? datatype #nil) | |
120 | + | (when (json-null? datatype) | |
121 | 121 | (set! datatype (xsd-iri "double"))) | |
122 | 122 | (set! value (canonical-double value))) | |
123 | 123 | ;; 11 | |
124 | 124 | ((number? value) | |
125 | 125 | (set! value (number->string (inexact->exact value))) | |
126 | - | (when (equal? datatype #nil) | |
126 | + | (when (json-null? datatype) | |
127 | 127 | (set! datatype (xsd-iri "integer")))) | |
128 | 128 | ;; 12 | |
129 | - | ((equal? datatype #nil) | |
129 | + | ((json-null? datatype) | |
130 | 130 | (set! datatype | |
131 | 131 | (if (json-has-key? item "@language") | |
132 | 132 | (rdf-iri "langString") | |
133 | 133 | (xsd-iri "string"))))) | |
134 | 134 | (if (and (json-has-key? item "@direction") (not (equal? rdf-direction #f))) | |
135 | 135 | ;; 13 | |
136 | - | (let* ((language (or (assoc-ref item "@language") "")) | |
136 | + | (let* ((language (or (not-null-or-false (assoc-ref item "@language")) "")) | |
137 | 137 | (language (string-downcase language))) | |
138 | 138 | (if (equal? rdf-direction "i18n-datatype") | |
139 | 139 | ;; 13.2 | |
… | |||
146 | 146 | ;; 13.3 | |
147 | 147 | (when (equal? rdf-direction "compound-literal") | |
148 | 148 | (let ((literal (blank-node->rdf-blank-node | |
149 | - | (generate-blank-node #nil)))) | |
149 | + | (generate-blank-node json-null)))) | |
150 | 150 | ;; 13.3.2 | |
151 | 151 | (set! list-triples | |
152 | 152 | (cons |
jsonld/rdf-to-object.scm
33 | 33 | (let ((result '()) | |
34 | 34 | (converted-value (rdf-literal-lexical-form value)) | |
35 | 35 | (datatype (rdf-literal-type value)) | |
36 | - | (type #nil)) | |
36 | + | (type json-null)) | |
37 | 37 | (cond | |
38 | 38 | ;; 2.4 | |
39 | 39 | (use-native-types? | |
… | |||
98 | 98 | ;; 2.9 | |
99 | 99 | (set! result (alist-set result "@value" converted-value)) | |
100 | 100 | ;; 2.10 | |
101 | - | (when type | |
101 | + | (when (not-null-or-false type) | |
102 | 102 | (set! result (alist-set result "@type" type))) | |
103 | 103 | ;; 2.11 | |
104 | 104 | result))) |
jsonld/term-selection.scm
22 | 22 | (define* (term-selection inverse-context var containers type/language | |
23 | 23 | preferred-values) | |
24 | 24 | (let ((container-map (assoc-ref inverse-context var)) | |
25 | - | (result #nil)) | |
25 | + | (result json-null)) | |
26 | 26 | ;; 2 | |
27 | 27 | (for-each | |
28 | 28 | (lambda (container) | |
… | |||
35 | 35 | (for-each | |
36 | 36 | (lambda (item) | |
37 | 37 | (when (json-has-key? value-map item) | |
38 | - | (unless result | |
38 | + | (unless (not-null-or-false result) | |
39 | 39 | (set! result (assoc-ref value-map item))))) | |
40 | 40 | preferred-values)))) | |
41 | 41 | containers) |
jsonld/value-compaction.scm
25 | 25 | (define (container-mapping active-context active-property) | |
26 | 26 | (let* ((def (term-definition-ref active-context active-property)) | |
27 | 27 | (container-mapping | |
28 | - | (if def (or (term-definition-container def) #()) #()))) | |
28 | + | (if (term-definition? def) | |
29 | + | (or (not-null-or-false (term-definition-container def)) #()) | |
30 | + | #()))) | |
29 | 31 | (if (json-array? container-mapping) | |
30 | 32 | (array->list container-mapping) | |
31 | 33 | (list container-mapping)))) | |
… | |||
35 | 37 | (let* ((result value) | |
36 | 38 | (active-def (term-definition-ref active-context active-property)) | |
37 | 39 | ;; 2 | |
38 | - | (language (if active-def (term-definition-language active-def) #f)) | |
40 | + | (language (if (term-definition? active-def) | |
41 | + | (term-definition-language active-def) | |
42 | + | #f)) | |
39 | 43 | ;; 3 | |
40 | - | (direction (if active-def (term-definition-direction active-def) #f))) | |
44 | + | (direction (if (term-definition? active-def) | |
45 | + | (term-definition-direction active-def) | |
46 | + | #f))) | |
41 | 47 | (when (equal? language #f) | |
42 | 48 | (set! language (active-context-language active-context))) | |
43 | 49 | (when (equal? direction #f) | |
… | |||
50 | 56 | (not (member (car kv) '("@id" "@index")))) | |
51 | 57 | value))) | |
52 | 58 | (cond | |
53 | - | ((and active-def (equal? (term-definition-type active-def) "@id")) | |
59 | + | ((and (term-definition? active-def) | |
60 | + | (equal? (term-definition-type active-def) "@id")) | |
54 | 61 | (set! result (iri-compaction active-context inverse-context | |
55 | 62 | (assoc-ref value "@id") #:vocab? #f | |
56 | 63 | #:processing-mode processing-mode))) | |
57 | - | ((and active-def (equal? (term-definition-type active-def) "@vocab")) | |
64 | + | ((and (term-definition? active-def) | |
65 | + | (equal? (term-definition-type active-def) "@vocab")) | |
58 | 66 | (set! result (iri-compaction active-context inverse-context | |
59 | 67 | (assoc-ref value "@id") #:vocab? #t | |
60 | 68 | #:processing-mode processing-mode))))) | |
61 | 69 | ;; 5 | |
62 | 70 | ((and (json-has-key? value "@type") | |
63 | - | active-def | |
71 | + | (term-definition? active-def) | |
64 | 72 | (equal? (assoc-ref value "@type") | |
65 | 73 | (term-definition-type active-def))) | |
66 | 74 | (set! result (assoc-ref value "@value"))) | |
67 | 75 | ;; 6 | |
68 | - | ((or (and active-def (equal? (term-definition-type active-def) "@none")) | |
76 | + | ((or (and (term-definition? active-def) | |
77 | + | (equal? (term-definition-type active-def) "@none")) | |
69 | 78 | (json-has-key? value "@type")) | |
70 | 79 | (when (json-has-key? result "@type") | |
71 | 80 | (let ((type (iri-compaction active-context inverse-context | |
… | |||
85 | 94 | (json-has-key? value "@value") | |
86 | 95 | (not (string? (assoc-ref value "@value")))) | |
87 | 96 | (when (or (and (json-has-key? value "@index") | |
88 | - | active-def | |
97 | + | (term-definition? active-def) | |
89 | 98 | (member "@index" (container-mapping active-context | |
90 | 99 | active-property))) | |
91 | 100 | (not (json-has-key? value "@index"))) | |
92 | 101 | (set! result (assoc-ref value "@value")))) | |
93 | 102 | ;; 8 | |
94 | - | ((and (or (and language (equal? language (assoc-ref value "@language"))) | |
95 | - | (and (not language) | |
103 | + | ((and (or (and (not-null-or-false language) | |
104 | + | (equal? language (assoc-ref value "@language"))) | |
105 | + | (and (not (not-null-or-false language)) | |
96 | 106 | (not (json-has-key? value "@language")))) | |
97 | - | (or (and direction (equal? direction (assoc-ref value "@direction"))) | |
98 | - | (and (not direction) | |
107 | + | (or (and (not-null-or-false direction) | |
108 | + | (equal? direction (assoc-ref value "@direction"))) | |
109 | + | (and (not (not-null-or-false direction)) | |
99 | 110 | (not (json-has-key? value "@direction"))))) | |
100 | 111 | (when (or (and (json-has-key? value "@index") | |
101 | - | active-def | |
112 | + | (term-definition? active-def) | |
102 | 113 | (member "@index" (container-mapping | |
103 | 114 | active-context active-property))) | |
104 | 115 | (not (json-has-key? value "@index"))) |
jsonld/value-expansion.scm
68 | 68 | (set! result (alist-set result "@type" type-mapping))) | |
69 | 69 | ;; 5 | |
70 | 70 | (when (string? value) | |
71 | - | (let* ((language (or language-mapping (active-context-language active-context))) | |
72 | - | (direction (or direction-mapping (active-context-direction active-context)))) | |
73 | - | (when (equal? language-mapping #nil) | |
74 | - | (set! language #nil)) | |
75 | - | (when (equal? direction-mapping #nil) | |
76 | - | (set! direction #nil)) | |
77 | - | (when language | |
71 | + | (let* ((language (or (not-null-or-false language-mapping) | |
72 | + | (active-context-language active-context))) | |
73 | + | (direction (or (not-null-or-false direction-mapping) | |
74 | + | (active-context-direction active-context)))) | |
75 | + | (when (json-null? language-mapping) | |
76 | + | (set! language json-null)) | |
77 | + | (when (json-null? direction-mapping) | |
78 | + | (set! direction json-null)) | |
79 | + | (when (not-null-or-false language) | |
78 | 80 | (set! result (alist-set result "@language" language))) | |
79 | - | (when direction | |
81 | + | (when (not-null-or-false direction) | |
80 | 82 | (set! result (alist-set result "@direction" direction))))) | |
81 | 83 | ;; 6 | |
82 | 84 | result))))) |