File: safe.ml

package info (click to toggle)
yojson 1.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 252 kB
  • sloc: ml: 1,957; makefile: 208
file content (16 lines) | stat: -rw-r--r-- 420 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
(* $Id$ *)

let rec to_basic : json -> Basic.json = function
    `Null
  | `Bool _
  | `Int _
  | `Float _
  | `String _ as x -> x
  | `Intlit s -> `String s
  | `List l
  | `Tuple l ->
      `List (List.rev (List.rev_map to_basic l))
  | `Assoc l ->
      `Assoc (List.rev (List.rev_map (fun (k, v) -> (k, to_basic v)) l))
  | `Variant (k, None) -> `String k
  | `Variant (k, Some v) -> `List [ `String k; to_basic v ]