package apero-core

  1. Overview
  2. Docs

Source file json.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
open Acommon.Result
module Json = struct

  type t = Yojson.Safe.t

  let to_string j = Yojson.Safe.to_string j

  let of_string s = Yojson.Safe.from_string s

  let validate s = 
    try
      let j = of_string s in
      let _ = Yojson.Safe.validate_json [] j in
      return j
    with
    | e -> 
      let (r:Atypes.error) = (`ValidationError (`Msg (Printexc.to_string e))) in 
      fail r

end