grokking simplicity and refactoring
This commit is contained in:
parent
89a7fe100d
commit
fb4361d938
67 changed files with 6275 additions and 56 deletions
21
packages/lab-tool/utils/json/parse.scm
Normal file
21
packages/lab-tool/utils/json/parse.scm
Normal file
|
@ -0,0 +1,21 @@
|
|||
;; utils/json/parse.scm - Pure JSON parsing functions
|
||||
|
||||
(define-module (utils json parse)
|
||||
#:use-module (json)
|
||||
#:export (json-string->scm-safe
|
||||
parse-json-pure))
|
||||
|
||||
;; Pure function: Safely parse JSON string
|
||||
;; Input: json-string
|
||||
;; Output: parsed scheme object or #f if invalid
|
||||
(define (parse-json-pure json-string)
|
||||
"Pure function to parse JSON string without side effects"
|
||||
(catch #t
|
||||
(lambda ()
|
||||
(if (string? json-string)
|
||||
(json-string->scm json-string)
|
||||
#f))
|
||||
(lambda (key . args) #f)))
|
||||
|
||||
;; Alias for compatibility
|
||||
(define json-string->scm-safe parse-json-pure)
|
Loading…
Add table
Add a link
Reference in a new issue