Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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",
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It won't build with rewatch?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glennsl it will. I just scoped the changes while working on updating my work projects. I've updated the commands, I tested them, and they work fine. fmt would re-format the project, but I decided not to stage the changes. I can do it in a separate commit or a PR if you like

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Thanks! Yes, a separate commit for the formatting changes would be nice.

"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