Skip to content

Compatibility with rescript 12 #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"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 legacy build -with-deps",
"start": "rescript legacy build -w -with-deps",
"clean": "rescript clean",
"fmt": "rescript format -all",
"test": "true"
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.1"
}
}
File renamed without changes.
9 changes: 6 additions & 3 deletions src/Json.res
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,16 @@ 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