Add typed/json which exports almost all of json
Does not include support for custom nulls, but is otherwise entirely functional. Closes #3.
This commit is contained in:
parent
ca88457092
commit
9fe834d35c
|
@ -78,6 +78,7 @@ The following libraries are included with Typed Racket in the
|
|||
@defmodule/incl[typed/rackunit]
|
||||
@defmodule/incl[typed/srfi/14]
|
||||
@defmodule/incl[typed/syntax/stx]
|
||||
@defmodule/incl[typed/json]
|
||||
|
||||
Other libraries included in the main distribution that are either
|
||||
written in Typed Racket or have adapter modules that are typed:
|
||||
|
|
19
typed-racket-more/typed/json.rkt
Normal file
19
typed-racket-more/typed/json.rkt
Normal file
|
@ -0,0 +1,19 @@
|
|||
#lang typed/racket/base
|
||||
|
||||
;; a typed wrapper for the json library
|
||||
|
||||
(provide JSExpr)
|
||||
|
||||
(define-type JSExpr
|
||||
(U 'null Boolean String Integer Inexact-Real (Listof JSExpr) (HashTable Symbol JSExpr)))
|
||||
|
||||
(require/typed/provide json
|
||||
[jsexpr? (Any -> Boolean)]
|
||||
[write-json (->* (JSExpr)
|
||||
(Output-Port #:encode (U 'control 'all))
|
||||
Any)]
|
||||
[read-json (->* () (Input-Port) (U JSExpr EOF))]
|
||||
[jsexpr->string (JSExpr [#:encode (U 'control 'all)] -> String)]
|
||||
[jsexpr->bytes (JSExpr [#:encode (U 'control 'all)] -> Bytes)]
|
||||
[string->jsexpr (String -> JSExpr)]
|
||||
[bytes->jsexpr (Bytes -> JSExpr)])
|
Loading…
Reference in New Issue
Block a user