Revision 1aea321361ed8ed117b4c084031a41d1c5d7b824 authored by Marge Bot on 22 February 2024, 09:46:18 UTC, committed by Marge Bot on 22 February 2024, 09:46:18 UTC
Co-authored-by: Rodi-Can Bozman <rodi.bozman@functori.com>

Approved-by: Pierrick Couderc <pierrick.couderc@nomadic-labs.com>
Approved-by: Rodi-Can Bozman <rodi.bozman@functori.com>
Approved-by: Arnaud Bihan <arnaud.bihan@functori.com>

See merge request https://gitlab.com/tezos/tezos/-/merge_requests/12130
2 parent s ae06881 + 7f100dc
Raw File
JSON_AST.ml
type t =
  [ `Null
  | `Bool of bool
  | `Float of float
  | `String of string
  | `O of (string * t) list
  | `A of t list ]

let f = Format.fprintf

let rec pp fmt = function
  | `Null -> f fmt "null"
  | `Bool x -> f fmt "%b" x
  | `Float x -> f fmt "%g" x
  | `String x -> f fmt "%S" x
  | `O l ->
      f fmt "@[<hv 2>{@ " ;
      List.iteri
        (fun i (k, v) ->
          if i <> 0 then f fmt ",@ " ;
          f fmt "%S: %a" k pp v)
        l ;
      f fmt "@ }@]"
  | `A l ->
      f fmt "@[<hv 2>[@ " ;
      List.iteri
        (fun i x ->
          if i <> 0 then f fmt ",@ " ;
          f fmt "%a" pp x)
        l ;
      f fmt "@ ]@]"
back to top