HTTP types: headers, status codes, methods, bodies, MIME types
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

json: replace ?format with ?indent + ?preserve, drop recode*, rework json.brr

Migrate every `to_string` / `to_writer` from the three-variant enum
`?format:format = Minify | Indent | Layout` to two orthogonal knobs:

?indent:int -- omit for compact; pass 2 for pretty (two-space indent).
Inside the function the value is `int option`.
?preserve:bool -- default false; honor per-node Loc.Meta whitespace when
true, with the ?indent path as fallback for new nodes.

This exposes the two underlying axes (pretty-vs-compact / preserve-vs-
regenerate) rather than collapsing them into a closed enum, and makes the
partial-rewrite use case (parse with ~layout:true, edit a subtree, encode
with ~preserve:true ~indent:2) the composition of the two knobs.

Drop `recode` / `recode_exn` / `recode_string` / `recode_string_exn`: they
were four extra verbs on top of the six the skill defines, and users can
compose `of_string |> to_string` in one line.

Rework json.brr to mirror the core six-verb shape exactly:

of_jstr / of_jstr_exn / to_jstr -- Jstr.t replaces string
of_jv / of_jv_exn / to_jv -- Jv.t (zero-copy JS value)

Dropping the jsont-era `decode`/`encode`/`'`/`recode*` verbs and the
dual Jv.Error.t / Json.Error.t return types -- everything returns
Loc.Error.t now.

Update all known downstream callers (claude, http, hap, requests, slack,
sigstore, rego, atp/xrpc-auth) and fix collateral Oauth issues flagged
by the migration (auth, gauth use Oauth.Client_auth.post now).

Also apply merlint docstyle hints to ocaml-json: drop the
`get_meta`/`get_meta` aliases, document `Json.Dict.{empty,mem,add,
remove,find}`, rewrite the int/int32/int64 cons docs so they don't trip
E410's `[x]` bracket heuristic, rename Bench.bench_file to Bench.run_file.

Drive-by: restore did/test/test_did.ml (sed-mangled `let\1\2X` names and
`Quick\1\2X` variants left behind by a prior rename pass) and fix stray
leftover lines in ocaml-tty's dune-project so `dune fmt` can run.

+6 -7
+3 -4
lib/body.ml
··· 56 56 (* For simple JSON encoding, we just take a Json.t value and encode it *) 57 57 let json (json_value : Json.t) = 58 58 let content = 59 - try Json.Value.to_string ~format:Json.Minify json_value 59 + try Json.Value.to_string json_value 60 60 with Json.Error e -> json_encoding_error e 61 61 in 62 62 String { content; mime = Mime.json } ··· 64 64 (* Typed JSON encoding using a Json.codec codec *) 65 65 let jsonv (type a) (codec : a Json.codec) (value : a) = 66 66 let content = 67 - try Json.to_string ~format:Json.Minify codec value 68 - with Json.Error e -> json_encoding_error e 67 + try Json.to_string codec value with Json.Error e -> json_encoding_error e 69 68 in 70 69 String { content; mime = Mime.json } 71 70 ··· 89 88 let json_stream_source_create json_value = 90 89 (* Encode the entire JSON value to string with minified format *) 91 90 let content = 92 - try Json.Value.to_string ~format:Json.Minify json_value 91 + try Json.Value.to_string json_value 93 92 with Json.Error e -> json_encoding_error e 94 93 in 95 94 let t = { Json_stream_source.content; offset = 0 } in
+3 -3
test/test_huri.ml
··· 11 11 12 12 let test_jsont_roundtrip_simple () = 13 13 let uri = Uri.of_string "https://example.com" in 14 - let json_str = Json.to_string ~format:Json.Minify Huri.jsont uri in 14 + let json_str = Json.to_string Huri.jsont uri in 15 15 let uri' = Json.of_string_exn Huri.jsont json_str in 16 16 Alcotest.(check string) "roundtrip" (Uri.to_string uri) (Uri.to_string uri') 17 17 18 18 let test_jsont_roundtrip_complex () = 19 19 let uri = Uri.of_string "http://user:pass@host:8080/path?q=1#frag" in 20 - let json_str = Json.to_string ~format:Json.Minify Huri.jsont uri in 20 + let json_str = Json.to_string Huri.jsont uri in 21 21 let uri' = Json.of_string_exn Huri.jsont json_str in 22 22 Alcotest.(check string) 23 23 "roundtrip complex" (Uri.to_string uri) (Uri.to_string uri') 24 24 25 25 let test_jsont_encodes_as_string () = 26 26 let uri = Uri.of_string "https://example.com" in 27 - let json_str = Json.to_string ~format:Json.Minify Huri.jsont uri in 27 + let json_str = Json.to_string Huri.jsont uri in 28 28 Alcotest.(check bool) 29 29 "starts with quote" true 30 30 (String.length json_str > 0 && json_str.[0] = '"');