Source

spotxtras / xjson.mli

Full commit
open Spotlib.Spot
open Tiny_json

val ocaml_of_t : Json.t Ocaml_conv.encoder
val t_of_ocaml : Json.t Ocaml_conv.decoder
val parse : string -> [> `Error of [> `Json_parse of exn ] | `Ok of Json.t ]

module Error : sig
  type t =
    [ `Json_conv of Json.t Meta_conv.Error.t (** conversion error from JSON to OCaml value *)
    | `Json_parse of exn (** parser error of JSON *)
    | Xcurl.Error.t
    ]

  val format : Format.t -> [< t ] -> unit

  val wrap_json_conv :
    'a Json_conv.decoder 
    -> Json.t
    -> [> ('a, [> `Json_conv of Json.t Meta_conv.Error.t ]) Result.t ]
end

val curl_get_and_parse :
  'a Json_conv.decoder 
  -> (Curl.handle -> unit) 
  -> ('a, [> `Http of int * [> `Message of string ]
          |  `Curl of int * string
          |  `Json_conv of Json.t Meta_conv.Error.t
          |  `Json_parse of exn ]) Result.t