File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change 2222 "dependencies" : {
2323 "purescript-prelude" : " ^6.0.1" ,
2424 "purescript-functions" : " ^6.0.0" ,
25+ "purescript-integers" : " ^6.0.0" ,
2526 "purescript-maybe" : " ^6.0.0" ,
2627 "purescript-either" : " ^6.1.0" ,
2728 "purescript-tuples" : " ^7.0.0" ,
Original file line number Diff line number Diff line change @@ -27,6 +27,7 @@ import Prelude
2727import Data.Either (Either (..))
2828import Data.Function.Uncurried (runFn2 , runFn3 , runFn7 )
2929import Data.Maybe (Maybe (..))
30+ import Data.Int as Int
3031import JSON.Internal (JArray , JObject , JSON ) as Exports
3132import JSON.Internal (JArray , JObject , JSON )
3233import JSON.Internal as Internal
@@ -119,6 +120,12 @@ toBoolean json = runFn7 Internal._case fail Just fail fail fail fail json
119120toNumber :: JSON -> Maybe Number
120121toNumber json = runFn7 Internal ._case fail fail Just fail fail fail json
121122
123+ -- | Converts a `JSON` `Number` into an `Int`.
124+ -- |
125+ -- | This is provided for convenience only.
126+ toInt :: Json -> Maybe Int
127+ toInt = toNumber >=> Int .fromNumber
128+
122129-- | Converts a `JSON` value to `String` if the `JSON` is a string.
123130toString :: JSON -> Maybe String
124131toString json = runFn7 Internal ._case fail fail fail Just fail fail json
You can’t perform that action at this time.
0 commit comments