+6
-3
lib/check/message_format.ml
+6
-3
lib/check/message_format.ml
···
90
90
91
91
Object (with_extract, Meta.none)
92
92
93
-
let format_json ?system_id messages =
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
-
let obj = Object ([ (("messages", Meta.none), msg_array) ], Meta.none) in
97
-
match Jsont_bytesrw.encode_string ~format:Minify json obj with
96
+
Object ([ (("messages", Meta.none), msg_array) ], Meta.none)
97
+
98
+
let format_json ?system_id messages =
99
+
let obj = messages_to_json ?system_id messages in
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
+33
lib/check/message_format.mli
···
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
+
30
+
(** {1 JSON Value Builders}
31
+
32
+
These functions return [Jsont.json] values that can be reused
33
+
for custom JSON encoding scenarios. *)
34
+
35
+
(** Convert a single message to JSON AST.
36
+
37
+
Produces JSON compatible with the Nu HTML Validator format:
38
+
{[
39
+
{
40
+
"type": "error",
41
+
"message": "...",
42
+
"subType": "error-code",
43
+
"url": "...",
44
+
"firstLine": 1,
45
+
"firstColumn": 1,
46
+
...
47
+
}
48
+
]}
49
+
50
+
@param system_id Default system identifier for messages without location.system_id. *)
51
+
val message_to_json : ?system_id:string -> Message.t -> Jsont.json
52
+
53
+
(** Convert a message list to JSON AST with wrapper object.
54
+
55
+
Produces JSON with a "messages" array:
56
+
{[
57
+
{ "messages": [...] }
58
+
]}
59
+
60
+
@param system_id Default system identifier for messages without location.system_id. *)
61
+
val messages_to_json : ?system_id:string -> Message.t list -> Jsont.json