Skip to content

Commit

Permalink
Add FFI definitions for json along with a JSON parser
Browse files Browse the repository at this point in the history
  • Loading branch information
anttih committed May 20, 2024
1 parent f658c8e commit 3cc62c4
Show file tree
Hide file tree
Showing 9 changed files with 671 additions and 1 deletion.
18 changes: 18 additions & 0 deletions json/spago.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package:
name: json
dependencies:
- prelude
- arrays
- functions
- integers
- maybe
- either
- tuples
- foldable-traversable
- gen
- strings
- unfoldable
test:
main: Test.JSON.Main
dependencies:
- assert
31 changes: 31 additions & 0 deletions json/src/JSON.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
(library (JSON foreign)
(export _null
fromBoolean
fromInt
fromString
fromJArray
fromJObject
print
printIndented)
(import (chezscheme)
(only (JSON.Internal foreign) json-stringify))

(define (coerce x) x)

(define _null 'null)

(define fromBoolean coerce)

(define fromInt inexact)

(define fromString coerce)

(define fromJArray coerce)

(define fromJObject coerce)

(define print json-stringify)

(define printIndented json-stringify)

)
9 changes: 9 additions & 0 deletions json/src/JSON/Array.ss
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
(library (JSON.Array foreign)
(export singleton)
(import (chezscheme)
(prefix (purs runtime srfi :214) srfi:214:))

(define (singleton x) (srfi:214:flexvector x))

)

Loading

0 comments on commit 3cc62c4

Please sign in to comment.