add json.ml; add test.ml; timestamp jsont

This commit is contained in:
Swrup 2025-10-03 18:14:17 +02:00
parent 04bb29b30c
commit 724a3d2b68
8 changed files with 89 additions and 22 deletions

View file

@ -1,28 +1,15 @@
(* https://docs.taler.net/core/api-common.html#tsref-type-ErrorDetail *)
module ErrorDetail = struct
module Error_detail = struct
(* TODO GANA error codes
https://git.gnunet.org/gana.git/tree/gnu-taler-error-codes/registry.rec *)
type t = { code: int; hint: string option }
let make code hint = { code; hint }
let enc_code v = v.code
let enc_hint v = v.hint
let jsont =
Jsont.Object.map ~kind:"ErrorDetail" make
|> Jsont.Object.mem "code" Jsont.int ~enc:enc_code
|> Jsont.Object.opt_mem "hint" Jsont.(string) ~enc:enc_hint
|> Jsont.Object.finish
let to_string v = Jsont_bytesrw.encode_string jsont v |> Result.get_ok
let of_string v = Jsont_bytesrw.decode_string jsont v
end
module Timestamp = struct
(* Seconds since epoch, or the special
value "never" to represent an event that will
never happen. *)
type t = Never | Seconds of int
type t = Never | Seconds of float
end
module Amount = struct