tangled
alpha
login
or
join now
anil.recoil.org
/
ocaml-html5rw
1
fork
atom
OCaml HTML5 parser/serialiser based on Python's JustHTML
1
fork
atom
overview
issues
pulls
pipelines
expose jsont
anil.recoil.org
3 months ago
8c373cab
baa9a32e
0/1
build.yml
failed
4m 47s
+39
-3
2 changed files
expand all
collapse all
unified
split
lib
check
message_format.ml
message_format.mli
+6
-3
lib/check/message_format.ml
reviewed
···
90
90
91
91
Object (with_extract, Meta.none)
92
92
93
93
-
let format_json ?system_id messages =
93
93
+
let messages_to_json ?system_id messages =
94
94
let open Jsont in
95
95
let msg_array = Array (List.map (message_to_json ?system_id) messages, Meta.none) in
96
96
-
let obj = Object ([ (("messages", Meta.none), msg_array) ], Meta.none) in
97
97
-
match Jsont_bytesrw.encode_string ~format:Minify json obj with
96
96
+
Object ([ (("messages", Meta.none), msg_array) ], Meta.none)
97
97
+
98
98
+
let format_json ?system_id messages =
99
99
+
let obj = messages_to_json ?system_id messages in
100
100
+
match Jsont_bytesrw.encode_string ~format:Minify Jsont.json obj with
98
101
| Ok s -> s
99
102
| Error e -> failwith ("JSON encoding error: " ^ e)
+33
lib/check/message_format.mli
reviewed
···
26
26
27
27
@param system_id Optional default system identifier for messages without location. *)
28
28
val format_gnu : ?system_id:string -> Message.t list -> string
29
29
+
30
30
+
(** {1 JSON Value Builders}
31
31
+
32
32
+
These functions return [Jsont.json] values that can be reused
33
33
+
for custom JSON encoding scenarios. *)
34
34
+
35
35
+
(** Convert a single message to JSON AST.
36
36
+
37
37
+
Produces JSON compatible with the Nu HTML Validator format:
38
38
+
{[
39
39
+
{
40
40
+
"type": "error",
41
41
+
"message": "...",
42
42
+
"subType": "error-code",
43
43
+
"url": "...",
44
44
+
"firstLine": 1,
45
45
+
"firstColumn": 1,
46
46
+
...
47
47
+
}
48
48
+
]}
49
49
+
50
50
+
@param system_id Default system identifier for messages without location.system_id. *)
51
51
+
val message_to_json : ?system_id:string -> Message.t -> Jsont.json
52
52
+
53
53
+
(** Convert a message list to JSON AST with wrapper object.
54
54
+
55
55
+
Produces JSON with a "messages" array:
56
56
+
{[
57
57
+
{ "messages": [...] }
58
58
+
]}
59
59
+
60
60
+
@param system_id Default system identifier for messages without location.system_id. *)
61
61
+
val messages_to_json : ?system_id:string -> Message.t list -> Jsont.json