Commit a4bf8bd8 authored by Johannes Kanig's avatar Johannes Kanig Committed by Sylvain Dailler

PB23-035 enrich information in .spark files

For every check, we now print the "check_tree" into the JSON output.
This is basically a dump of the session tree, just in a different
format.

* json.ml
new json datatype and new function "print_json" to print it

Change-Id: I0b28ac181793af4d160abc58c2634b3cbcac9b94
parent f9e2170a
......@@ -44,3 +44,21 @@ let map_bindings key_to_str value_pr fmt map_bindings =
else
Pp.print_list_delim ~start:Pp.lbrace ~stop:Pp.rbrace ~sep:Pp.comma
(print_map_binding key_to_str value_pr) fmt map_bindings
type json =
| Int of int
| Float of float
| Bool of bool
| String of string
| List of json list
| Record of json Stdlib.Mstr.t
let rec print_json fmt j =
match j with
| Int i -> int fmt i
| Float f -> float fmt f
| Bool b -> bool fmt b
| String s -> string fmt s
| List l -> list print_json fmt l
| Record r ->
map_bindings (fun x -> x) print_json fmt (Stdlib.Mstr.bindings r)
......@@ -9,6 +9,8 @@
(* *)
(********************************************************************)
(* use the simple printer functions to quickly print some JSON *)
val string : Format.formatter -> string -> unit
(* print json string, that is add '"' to the front and back, and escape '"' and
'\' in the string *)
......@@ -42,3 +44,17 @@ 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. *)
(* for more complex applications it may be convenient to build a an
explicit JSON object. Use this type for that and the print_json
function to print it *)
type json =
| Int of int
| Float of float
| Bool of bool
| String of string
| List of json list
| Record of json Stdlib.Mstr.t
val print_json : Format.formatter -> json -> unit
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