type json =
  | JNull
  | JBool of bool
  | JInt of int
  | JStr of string
  | JList of json list

let rec to_string j =
  match j with
  | JNull -> "null"
  | JBool b -> if b then "true" else "false"
  | JInt n -> string_of_int n
  | JStr s -> "\"" ^ s ^ "\""
  | JList xs ->
    "[" ^ String.concat "," (List.map to_string xs) ^ "]"

;;

let j = JList [JInt 1; JBool true; JNull; JStr "hi"; JList [JInt 2; JInt 3]] in
String.length (to_string j)
