forked from ocaml-community/yojson
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtype.ml
60 lines (59 loc) · 1.67 KB
/
type.ml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
(** {3 Type of the JSON tree} *)
type json =
[
| `Null
| `Bool of bool
#ifdef INT
| `Int of int
#endif
#ifdef INTLIT
| `Intlit of string
#endif
#ifdef FLOAT
| `Float of float
#endif
#ifdef FLOATLIT
| `Floatlit of string
#endif
#ifdef STRING
| `String of string
#endif
#ifdef STRINGLIT
| `Stringlit of string
#endif
| `Assoc of (string * json) list
| `List of json list
#ifdef TUPLE
| `Tuple of json list
#endif
#ifdef VARIANT
| `Variant of (string * json option)
#endif
]
(**
All possible cases defined in Yojson:
- `Null: JSON null
- `Bool of bool: JSON boolean
- `Int of int: JSON number without decimal point or exponent.
- `Intlit of string: JSON number without decimal point or exponent,
preserved as a string.
- `Float of float: JSON number, Infinity, -Infinity or NaN.
- `Floatlit of string: JSON number, Infinity, -Infinity or NaN,
preserved as a string.
- `String of string: JSON string. Bytes in the range 128-255 are preserved
as-is without encoding validation for both reading
and writing.
- `Stringlit of string: JSON string literal including the double quotes.
- `Assoc of (string * json) list: JSON object.
- `List of json list: JSON array.
- `Tuple of json list: Tuple (non-standard extension of JSON).
Syntax: [("abc", 123)].
- `Variant of (string * json option): Variant (non-standard extension of JSON).
Syntax: [<"Foo">] or [<"Bar":123>].
*)
(*
Note to adventurers: ocamldoc does not support inline comments
on each polymorphic variant, and cppo doesn't allow to concatenate
comments, so it would be complicated to document only the
cases that are preserved by cppo in the type definition.
*)