@@ -707,23 +707,23 @@ pub const JsonRPCMessage = union(enum) {
707707 test "emit_null_optional_fields" {
708708 try std .testing .expectFmt (
709709 \\{"jsonrpc":"2.0","method":"exit"}
710- , "{f}" , .{parser . jsonFmt (JsonRPCMessage { .notification = .{ .method = "exit" , .params = null } }, .{ .emit_null_optional_fields = false })});
710+ , "{f}" , .{std . json . fmt (JsonRPCMessage { .notification = .{ .method = "exit" , .params = null } }, .{ .emit_null_optional_fields = false })});
711711 try std .testing .expectFmt (
712712 \\{"jsonrpc":"2.0","method":"exit","params":null}
713- , "{f}" , .{parser . jsonFmt (JsonRPCMessage { .notification = .{ .method = "exit" , .params = null } }, .{ .emit_null_optional_fields = true })});
713+ , "{f}" , .{std . json . fmt (JsonRPCMessage { .notification = .{ .method = "exit" , .params = null } }, .{ .emit_null_optional_fields = true })});
714714 try std .testing .expectFmt (
715715 \\{"jsonrpc":"2.0","method":"exit","params":null}
716- , "{f}" , .{parser . jsonFmt (JsonRPCMessage { .notification = .{ .method = "exit" , .params = .null } }, .{ .emit_null_optional_fields = false })});
716+ , "{f}" , .{std . json . fmt (JsonRPCMessage { .notification = .{ .method = "exit" , .params = .null } }, .{ .emit_null_optional_fields = false })});
717717 try std .testing .expectFmt (
718718 \\{"jsonrpc":"2.0","method":"exit","params":null}
719- , "{f}" , .{parser . jsonFmt (JsonRPCMessage { .notification = .{ .method = "exit" , .params = .null } }, .{ .emit_null_optional_fields = true })});
719+ , "{f}" , .{std . json . fmt (JsonRPCMessage { .notification = .{ .method = "exit" , .params = .null } }, .{ .emit_null_optional_fields = true })});
720720
721721 try std .testing .expectFmt (
722722 \\{"jsonrpc":"2.0","result":null}
723- , "{f}" , .{parser . jsonFmt (JsonRPCMessage { .response = .{ .id = null , .result_or_error = .{ .result = null } } }, .{ .emit_null_optional_fields = false })});
723+ , "{f}" , .{std . json . fmt (JsonRPCMessage { .response = .{ .id = null , .result_or_error = .{ .result = null } } }, .{ .emit_null_optional_fields = false })});
724724 try std .testing .expectFmt (
725725 \\{"jsonrpc":"2.0","id":null,"result":null}
726- , "{f}" , .{parser . jsonFmt (JsonRPCMessage { .response = .{ .id = null , .result_or_error = .{ .result = null } } }, .{ .emit_null_optional_fields = true })});
726+ , "{f}" , .{std . json . fmt (JsonRPCMessage { .response = .{ .id = null , .result_or_error = .{ .result = null } } }, .{ .emit_null_optional_fields = true })});
727727 }
728728
729729 fn testParse (message : []const u8 , expected : JsonRPCMessage , parse_options : std.json.ParseOptions ) ! void {
@@ -738,10 +738,10 @@ pub const JsonRPCMessage = union(enum) {
738738 const parsed_from_value = try std .json .parseFromValue (JsonRPCMessage , allocator , parsed_value .value , parse_options );
739739 defer parsed_from_value .deinit ();
740740
741- const from_slice_stringified = try std .json .stringifyAlloc (allocator , parsed_from_slice .value , .{ .whitespace = .indent_2 });
741+ const from_slice_stringified = try std .json .Stringify . valueAlloc (allocator , parsed_from_slice .value , .{ .whitespace = .indent_2 });
742742 defer allocator .free (from_slice_stringified );
743743
744- const from_value_stringified = try std .json .stringifyAlloc (allocator , parsed_from_value .value , .{ .whitespace = .indent_2 });
744+ const from_value_stringified = try std .json .Stringify . valueAlloc (allocator , parsed_from_value .value , .{ .whitespace = .indent_2 });
745745 defer allocator .free (from_value_stringified );
746746
747747 if (! std .mem .eql (u8 , from_slice_stringified , from_value_stringified )) {
@@ -872,13 +872,13 @@ test TypedJsonRPCRequest {
872872
873873 try std .testing .expectFmt (
874874 \\{"jsonrpc":"2.0","id":42,"method":"name","params":null}
875- , "{f}" , .{parser . jsonFmt (Request { .id = .{ .number = 42 }, .method = "name" , .params = null }, .{})});
875+ , "{f}" , .{std . json . fmt (Request { .id = .{ .number = 42 }, .method = "name" , .params = null }, .{})});
876876 try std .testing .expectFmt (
877877 \\{"jsonrpc":"2.0","id":"42","method":"name"}
878- , "{f}" , .{parser . jsonFmt (Request { .id = .{ .string = "42" }, .method = "name" , .params = null }, .{ .emit_null_optional_fields = false })});
878+ , "{f}" , .{std . json . fmt (Request { .id = .{ .string = "42" }, .method = "name" , .params = null }, .{ .emit_null_optional_fields = false })});
879879 try std .testing .expectFmt (
880880 \\{"jsonrpc":"2.0","id":42,"method":"name","params":true}
881- , "{f}" , .{parser . jsonFmt (Request { .id = .{ .number = 42 }, .method = "name" , .params = true }, .{})});
881+ , "{f}" , .{std . json . fmt (Request { .id = .{ .number = 42 }, .method = "name" , .params = true }, .{})});
882882}
883883
884884pub fn TypedJsonRPCNotification (
@@ -924,13 +924,13 @@ test TypedJsonRPCNotification {
924924
925925 try std .testing .expectFmt (
926926 \\{"jsonrpc":"2.0","method":"name","params":null}
927- , "{f}" , .{parser . jsonFmt (Notification { .method = "name" , .params = null }, .{})});
927+ , "{f}" , .{std . json . fmt (Notification { .method = "name" , .params = null }, .{})});
928928 try std .testing .expectFmt (
929929 \\{"jsonrpc":"2.0","method":"name"}
930- , "{f}" , .{parser . jsonFmt (Notification { .method = "name" , .params = null }, .{ .emit_null_optional_fields = false })});
930+ , "{f}" , .{std . json . fmt (Notification { .method = "name" , .params = null }, .{ .emit_null_optional_fields = false })});
931931 try std .testing .expectFmt (
932932 \\{"jsonrpc":"2.0","method":"name","params":true}
933- , "{f}" , .{parser . jsonFmt (Notification { .method = "name" , .params = true }, .{})});
933+ , "{f}" , .{std . json . fmt (Notification { .method = "name" , .params = true }, .{})});
934934}
935935
936936pub fn TypedJsonRPCResponse (
@@ -982,13 +982,13 @@ test TypedJsonRPCResponse {
982982
983983 try std .testing .expectFmt (
984984 \\{"jsonrpc":"2.0","id":null,"error":{"code":-32600,"message":"message","data":null}}
985- , "{f}" , .{parser . jsonFmt (Response {
985+ , "{f}" , .{std . json . fmt (Response {
986986 .id = null ,
987987 .result_or_error = .{ .@"error" = .{ .code = .invalid_request , .message = "message" , .data = .null } },
988988 }, .{})});
989989 try std .testing .expectFmt (
990990 \\{"jsonrpc":"2.0","id":5,"result":true}
991- , "{f}" , .{parser . jsonFmt (Response {
991+ , "{f}" , .{std . json . fmt (Response {
992992 .id = .{ .number = 5 },
993993 .result_or_error = .{ .result = true },
994994 }, .{})});
@@ -1205,14 +1205,14 @@ pub const Transport = struct {
12051205 method : []const u8 ,
12061206 comptime Params : type ,
12071207 params : Params ,
1208- options : std.json.StringifyOptions ,
1208+ options : std.json.Stringify.Options ,
12091209 ) (WriteError || std .mem .Allocator .Error )! void {
12101210 const request : TypedJsonRPCRequest (Params ) = .{
12111211 .id = id ,
12121212 .method = method ,
12131213 .params = params ,
12141214 };
1215- const json_message = try std .json .stringifyAlloc (allocator , request , options );
1215+ const json_message = try std .json .Stringify . valueAlloc (allocator , request , options );
12161216 defer allocator .free (json_message );
12171217 try transport .writeJsonMessage (json_message );
12181218 }
@@ -1223,13 +1223,13 @@ pub const Transport = struct {
12231223 method : []const u8 ,
12241224 comptime Params : type ,
12251225 params : Params ,
1226- options : std.json.StringifyOptions ,
1226+ options : std.json.Stringify.Options ,
12271227 ) (WriteError || std .mem .Allocator .Error )! void {
12281228 const request : TypedJsonRPCNotification (Params ) = .{
12291229 .method = method ,
12301230 .params = params ,
12311231 };
1232- const json_message = try std .json .stringifyAlloc (allocator , request , options );
1232+ const json_message = try std .json .Stringify . valueAlloc (allocator , request , options );
12331233 defer allocator .free (json_message );
12341234 try transport .writeJsonMessage (json_message );
12351235 }
@@ -1240,13 +1240,13 @@ pub const Transport = struct {
12401240 id : ? JsonRPCMessage.ID ,
12411241 comptime Result : type ,
12421242 result : Result ,
1243- options : std.json.StringifyOptions ,
1243+ options : std.json.Stringify.Options ,
12441244 ) (WriteError || std .mem .Allocator .Error )! void {
12451245 const request : TypedJsonRPCResponse (Result ) = .{
12461246 .id = id ,
12471247 .result_or_error = .{ .result = result },
12481248 };
1249- const json_message = try std .json .stringifyAlloc (allocator , request , options );
1249+ const json_message = try std .json .Stringify . valueAlloc (allocator , request , options );
12501250 defer allocator .free (json_message );
12511251 try transport .writeJsonMessage (json_message );
12521252 }
@@ -1256,13 +1256,13 @@ pub const Transport = struct {
12561256 allocator : std.mem.Allocator ,
12571257 id : ? JsonRPCMessage.ID ,
12581258 err : JsonRPCMessage.Response.Error ,
1259- options : std.json.StringifyOptions ,
1259+ options : std.json.Stringify.Options ,
12601260 ) (WriteError || std .mem .Allocator .Error )! void {
12611261 const request : TypedJsonRPCResponse (void ) = .{
12621262 .id = id ,
12631263 .result_or_error = .{ .@"error" = err },
12641264 };
1265- const json_message = try std .json .stringifyAlloc (allocator , request , options );
1265+ const json_message = try std .json .Stringify . valueAlloc (allocator , request , options );
12661266 defer allocator .free (json_message );
12671267 try transport .writeJsonMessage (json_message );
12681268 }
@@ -1375,14 +1375,14 @@ pub fn writeRequest(
13751375 method : []const u8 ,
13761376 comptime Params : type ,
13771377 params : Params ,
1378- options : std.json.StringifyOptions ,
1378+ options : std.json.Stringify.Options ,
13791379) (std .io .Writer .Error || std .mem .Allocator .Error )! void {
13801380 const request : TypedJsonRPCRequest (Params ) = .{
13811381 .id = id ,
13821382 .method = method ,
13831383 .params = params ,
13841384 };
1385- const json_message = try std .json .stringifyAlloc (allocator , request , options );
1385+ const json_message = try std .json .Stringify . valueAlloc (allocator , request , options );
13861386 defer allocator .free (json_message );
13871387 try writeJsonMessage (writer , json_message );
13881388}
@@ -1418,13 +1418,13 @@ pub fn writeNotification(
14181418 method : []const u8 ,
14191419 comptime Params : type ,
14201420 params : Params ,
1421- options : std.json.StringifyOptions ,
1421+ options : std.json.Stringify.Options ,
14221422) (std .io .Writer .Error || std .mem .Allocator .Error )! void {
14231423 const request : TypedJsonRPCNotification (Params ) = .{
14241424 .method = method ,
14251425 .params = params ,
14261426 };
1427- const json_message = try std .json .stringifyAlloc (allocator , request , options );
1427+ const json_message = try std .json .Stringify . valueAlloc (allocator , request , options );
14281428 defer allocator .free (json_message );
14291429 try writeJsonMessage (writer , json_message );
14301430}
@@ -1458,13 +1458,13 @@ pub fn writeResponse(
14581458 id : ? JsonRPCMessage.ID ,
14591459 comptime Result : type ,
14601460 result : Result ,
1461- options : std.json.StringifyOptions ,
1461+ options : std.json.Stringify.Options ,
14621462) (std .io .Writer .Error || std .mem .Allocator .Error )! void {
14631463 const request : TypedJsonRPCResponse (Result ) = .{
14641464 .id = id ,
14651465 .result_or_error = .{ .result = result },
14661466 };
1467- const json_message = try std .json .stringifyAlloc (allocator , request , options );
1467+ const json_message = try std .json .Stringify . valueAlloc (allocator , request , options );
14681468 defer allocator .free (json_message );
14691469 try writeJsonMessage (writer , json_message );
14701470}
@@ -1497,13 +1497,13 @@ pub fn writeErrorResponse(
14971497 allocator : std.mem.Allocator ,
14981498 id : ? JsonRPCMessage.ID ,
14991499 err : JsonRPCMessage.Response.Error ,
1500- options : std.json.StringifyOptions ,
1500+ options : std.json.Stringify.Options ,
15011501) (std .io .Writer .Error || std .mem .Allocator .Error )! void {
15021502 const request : TypedJsonRPCResponse (void ) = .{
15031503 .id = id ,
15041504 .result_or_error = .{ .@"error" = err },
15051505 };
1506- const json_message = try std .json .stringifyAlloc (allocator , request , options );
1506+ const json_message = try std .json .Stringify . valueAlloc (allocator , request , options );
15071507 defer allocator .free (json_message );
15081508 try writeJsonMessage (writer , json_message );
15091509}
@@ -1571,7 +1571,7 @@ fn bufPrintLogMessageTypeErased(
15711571 var writer : std.io.Writer = .fixed (buffer );
15721572 writer .print (
15731573 \\{{"jsonrpc":"2.0","method":"window/logMessage","params":{{"type":{f},"message":"
1574- , .{parser . jsonFmt (message_type , .{})}) catch unreachable ;
1574+ , .{std . json . fmt (message_type , .{})}) catch unreachable ;
15751575
15761576 const json_message_suffix = "\" }}" .* ;
15771577 const ellipses = "..." .* ;
@@ -2332,9 +2332,9 @@ fn testMessageWithOptions(
23322332 const message_from_value = try std .json .parseFromValueLeaky (ExampleMessage , arena .allocator (), value , parse_options );
23332333 const message_from_slice = try ExampleMessage .parseFromSliceLeaky (arena .allocator (), json_message , parse_options );
23342334
2335- const message_string = try std .json .stringifyAlloc (arena .allocator (), message , .{ .whitespace = .indent_2 });
2336- const message_from_value_string = try std .json .stringifyAlloc (arena .allocator (), message_from_value , .{ .whitespace = .indent_2 });
2337- const message_from_slice_string = try std .json .stringifyAlloc (arena .allocator (), message_from_slice , .{ .whitespace = .indent_2 });
2335+ const message_string = try std .json .Stringify . valueAlloc (arena .allocator (), message , .{ .whitespace = .indent_2 });
2336+ const message_from_value_string = try std .json .Stringify . valueAlloc (arena .allocator (), message_from_value , .{ .whitespace = .indent_2 });
2337+ const message_from_slice_string = try std .json .Stringify . valueAlloc (arena .allocator (), message_from_slice , .{ .whitespace = .indent_2 });
23382338
23392339 try std .testing .expectEqualStrings (message_string , message_from_value_string );
23402340 try std .testing .expectEqualStrings (message_string , message_from_slice_string );
@@ -2422,23 +2422,23 @@ test "Message - ignore_unknown_fields" {
24222422test "Message - stringify emit_null_optional_fields" {
24232423 try std .testing .expectFmt (
24242424 \\{"jsonrpc":"2.0","method":"exit"}
2425- , "{f}" , .{parser . jsonFmt (ExampleMessage { .notification = .{ .params = .exit } }, .{ .emit_null_optional_fields = false })});
2425+ , "{f}" , .{std . json . fmt (ExampleMessage { .notification = .{ .params = .exit } }, .{ .emit_null_optional_fields = false })});
24262426 try std .testing .expectFmt (
24272427 \\{"jsonrpc":"2.0","method":"exit","params":null}
2428- , "{f}" , .{parser . jsonFmt (ExampleMessage { .notification = .{ .params = .exit } }, .{ .emit_null_optional_fields = true })});
2428+ , "{f}" , .{std . json . fmt (ExampleMessage { .notification = .{ .params = .exit } }, .{ .emit_null_optional_fields = true })});
24292429
24302430 try std .testing .expectFmt (
24312431 \\{"jsonrpc":"2.0","method":"foo"}
2432- , "{f}" , .{parser . jsonFmt (ExampleMessage { .notification = .{ .params = .{ .other = .{ .method = "foo" , .params = null } } } }, .{ .emit_null_optional_fields = false })});
2432+ , "{f}" , .{std . json . fmt (ExampleMessage { .notification = .{ .params = .{ .other = .{ .method = "foo" , .params = null } } } }, .{ .emit_null_optional_fields = false })});
24332433 try std .testing .expectFmt (
24342434 \\{"jsonrpc":"2.0","method":"foo","params":null}
2435- , "{f}" , .{parser . jsonFmt (ExampleMessage { .notification = .{ .params = .{ .other = .{ .method = "foo" , .params = null } } } }, .{ .emit_null_optional_fields = true })});
2435+ , "{f}" , .{std . json . fmt (ExampleMessage { .notification = .{ .params = .{ .other = .{ .method = "foo" , .params = null } } } }, .{ .emit_null_optional_fields = true })});
24362436 try std .testing .expectFmt (
24372437 \\{"jsonrpc":"2.0","method":"foo","params":null}
2438- , "{f}" , .{parser . jsonFmt (ExampleMessage { .notification = .{ .params = .{ .other = .{ .method = "foo" , .params = .null } } } }, .{ .emit_null_optional_fields = false })});
2438+ , "{f}" , .{std . json . fmt (ExampleMessage { .notification = .{ .params = .{ .other = .{ .method = "foo" , .params = .null } } } }, .{ .emit_null_optional_fields = false })});
24392439 try std .testing .expectFmt (
24402440 \\{"jsonrpc":"2.0","method":"foo","params":null}
2441- , "{f}" , .{parser . jsonFmt (ExampleMessage { .notification = .{ .params = .{ .other = .{ .method = "foo" , .params = .null } } } }, .{ .emit_null_optional_fields = true })});
2441+ , "{f}" , .{std . json . fmt (ExampleMessage { .notification = .{ .params = .{ .other = .{ .method = "foo" , .params = .null } } } }, .{ .emit_null_optional_fields = true })});
24422442}
24432443
24442444test "Message.Request" {
0 commit comments