Commit 76fb6b30 authored by Johannes Kanig's avatar Johannes Kanig

add some comments to JSON interface

parent f9a8faa3
......@@ -23,6 +23,8 @@ let string fmt s =
let int fmt d = Format.fprintf fmt "%d" d
let bool fmt b = Format.fprintf fmt "%b" b
let float fmt f = Format.fprintf fmt "%f" f
(* TODO check that you can print a floating point number like this in JSON *)
let print_json_field key value_pr fmt value =
Format.fprintf fmt "%a : %a " string key value_pr value
......
......@@ -10,18 +10,35 @@
(********************************************************************)
val string : Format.formatter -> string -> unit
(* print json string, that is add '"' to the front and back, and escape '"' and
'\' in the string *)
val int : Format.formatter -> int -> unit
(* print an integer *)
val bool : Format.formatter -> bool -> unit
(* print an boolean *)
val float : Format.formatter -> float -> unit
(* print an floating point number *)
val list :
(Format.formatter -> 'a -> unit) -> Format.formatter -> 'a list -> unit
(* provided a printer for elements, print a json list of these elements. In the
case of the empty list, print the json empty list [] *)
val map_bindings :
('a -> string) ->
(Format.formatter -> 'b -> unit) ->
('a -> string) ->
(Format.formatter -> 'b -> unit) ->
Format.formatter ->
('a * 'b) list ->
unit
(* arguments:
* a mapping from keys to strings;
* a printer of values
* the formatter
* a list of key,value pairs
action: print the list of key-value pairs as a json record, if the list is
empty, print the empty record *)
val print_json_field :
string -> (Format.formatter -> 'a -> unit) -> Format.formatter -> 'a -> unit
(* given a field name, a value and a printer for the value, print a json
mapping (field assignment). Do not print anything else. *)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment