Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 153 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
"version": "1.4.0",
"description": "Combinator library for JSON decoding and encoding. ",
"scripts": {
"build": "rescript build -with-deps",
"start": "rescript build -w -with-deps",
"build": "rescript build",
"start": "rescript watch",
"clean": "rescript clean",
"fmt": "rescript format -all",
"fmt": "rescript format -a",
"test": "true"
},
"engines": {
Expand All @@ -28,9 +28,9 @@
"homepage": "https://github.com/glennsl/rescript-json-combinators#readme",
"files": [
"src/*.res*",
"bsconfig.json"
"rescript.json"
],
"devDependencies": {
"rescript": "^11.0.1"
"rescript": "^12.0.0-beta.4"
}
}
File renamed without changes.
11 changes: 8 additions & 3 deletions src/Json.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,18 @@ let decode = Decode.decode

let parse = str =>
try Ok(str->Js.Json.parseExn) catch {
| Js.Exn.Error(ex) => Error(ex->Js.Exn.message->Js.Option.getWithDefault("Unknown error", _))
| ex =>
let message =
ex->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("Unknown error")
Error(message)
}

let parseExn = str =>
try str->Js.Json.parseExn catch {
| Js.Exn.Error(ex) =>
raise(ParseError(ex->Js.Exn.message->Js.Option.getWithDefault("Unknown error", _)))
| ex =>
let message =
ex->JsExn.fromException->Option.flatMap(JsExn.message)->Option.getOr("Unknown error")
throw(ParseError(message))
}

@val external stringify: Js.Json.t => string = "JSON.stringify"
Loading