Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Updated outdated docs according to the current API, fixed some exampl…
Browse files Browse the repository at this point in the history
…es (#78)

* Fixed typos in docs

* Updated outdated docs according to the current API

* Update src/Json_decode.mli

Co-authored-by: Glenn Slotte <glenn@slotte.net>
  • Loading branch information
evxn and glennsl committed Sep 13, 2020
1 parent 69d9ca3 commit 522ecc9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/Json.mli
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ This module has four aspects to it:
- Encoding, which is the process of construction a JSON data structure
- Decoding, which is the process of deconstructing a JSON data structure
{3 Parsing}
{! parse} and {! exnParse} will both (try to) parse a JSON string into a JSON
{! parse} and {! parseOrRaise} will both (try to) parse a JSON string into a JSON
data structure ({! Js.Json.t}), but behaves differently when encountering a
parse error. [exnParse] will raise a [SyntaxError], while [parse] will return
parse error. [parseOrRaise] will raise a [ParseError], while [parse] will return
a [Js.Json.t result] indicating whether or not the parsing succeeded. There's
not much more to it: [string] in, [Js.Json.t] out.
The parsed result, and encoded JSON data structure, then needs to be decoded to
Expand Down
14 changes: 7 additions & 7 deletions src/Json_decode.mli
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ val id : Js.Json.t decoder
val bool : bool decoder
(** Decodes a JSON value into a [bool]
{b Returns} a [bool] if the JSON value is a number.
{b Returns} a [bool] if the JSON value is a [true] or [false].
@raise [DecodeError] if unsuccessful
Expand Down Expand Up @@ -95,7 +95,7 @@ val int : int decoder
val string : string decoder
(** Decodes a JSON value into a [string]
{b Returns} a [string] if the JSON value is a number.
{b Returns} a [string] if the JSON value is a string.
@raise [DecodeError] if unsuccessful
Expand Down Expand Up @@ -129,7 +129,7 @@ val char : char decoder
*)

val date : Js.Date.t decoder
(** Decodes an ISO8601-fot\rmatted JSON string into a [Js.Date.t]
(** Decodes an ISO8601-formatted JSON string into a [Js.Date.t]
{b Returns} a [Js.Date.t] if the JSON value is an IS8601-formatted string.
Expand Down Expand Up @@ -189,7 +189,7 @@ elements are successfully decoded.
let _ = Json.parseOrRaise "[1, 2, "c"]" |> Decode.(array int)
(* raises DecodeError *)
let _ = Json.parseOrRaise "123" |> Decode.(array int)
(* returns None *)
(* raises DecodeError *)
let _ = Json.parseOrRaise "null" |> Decode.(array int)
]}
*)
Expand All @@ -210,7 +210,7 @@ elements are successfully decoded.
let _ = Json.parseOrRaise "[1, 2, "c"]" |> Decode.(list int)
(* raises DecodeError *)
let _ = Json.parseOrRaise "123" |> Decode.(list int)
(* returns None *)
(* raises DecodeError *)
let _ = Json.parseOrRaise "null" |> Decode.(list int)
]}
*)
Expand Down Expand Up @@ -293,7 +293,7 @@ values are successfully decoded.
let _ = Json.parseOrRaise {| { "x": 23, "y": "b" } |} |> Decode.(dict int)
(* raises DecodeError *)
let _ = Json.parseOrRaise "123" |> Decode.(dict int)
(* returns None *)
(* raises DecodeError *)
let _ = Json.parseOrRaise "null" |> Decode.(dict int)
]}
*)
Expand Down Expand Up @@ -434,7 +434,7 @@ val map : ('a -> 'b) -> 'a decoder -> 'b decoder
@example {[
open Json
(* returns 46 *)
let _ = Json.parseOrRaise "23" |> Decode.map (fun x -> x * x) int
let _ = Json.parseOrRaise "23" |> Decode.map (fun x -> x + x) int
]}
*)

Expand Down

0 comments on commit 522ecc9

Please sign in to comment.