Pass an optional option record to jsonld

Julien LepillerSun Oct 04 23:18:12+0200 2020

561cf3f

Pass an optional option record to jsonld

activitystreams/ontology.scm

395395
                      #f))))
396396
             document)))))))
397397
398-
(define (uri->as-document ontology uri)
399-
  (json->as-document ontology (expand uri)))
398+
(define* (uri->as-document ontology uri #:key (options #f))
399+
  (if options
400+
      (json->as-document ontology (expand uri #:options options))
401+
      (json->as-document ontology (expand uri))))
400402
401-
(define (as-document->json ontology doc)
403+
(define* (as-document->json ontology doc #:key (options #f))
402404
  (define (as-document->proper-json doc)
403405
    (append
404406
      `(("@type" . ,(list->array 1 (map as-type-uri (as-document-types doc)))))

429431
               '())))
430432
      (else doc)))
431433
432-
  (compact (as-value->proper-json doc)
433-
           `(("@context" . ,(list->array 1 (ontology-context ontology))))))
434+
  (let ((proper-json (as-value->proper-json doc))
435+
        (context `(("@context" . ,(list->array 1 (ontology-context ontology))))))
436+
    (if options
437+
        (compact proper-json context)
438+
        (compact proper-json context #:options options))))
434439
435440
(define* (as-document->graphviz doc #:key (label "n"))
436441
  (cond