@@ -112,7 +112,7 @@ struct Request
112112 token:: Union{CancellationTokens.CancellationToken,Nothing}
113113end
114114
115- mutable struct JSONRPCEndpoint{IOIn <: IO ,IOOut <: IO }
115+ mutable struct JSONRPCEndpoint{IOIn<: IO ,IOOut<: IO ,S <: JSON.Serialization }
116116 pipe_in:: IOIn
117117 pipe_out:: IOOut
118118
@@ -129,9 +129,11 @@ mutable struct JSONRPCEndpoint{IOIn <: IO,IOOut <: IO}
129129
130130 read_task:: Union{Nothing,Task}
131131 write_task:: Union{Nothing,Task}
132+
133+ serialization:: S
132134end
133135
134- JSONRPCEndpoint (pipe_in, pipe_out, err_handler = nothing ) =
136+ JSONRPCEndpoint (pipe_in, pipe_out, err_handler= nothing , serialization :: JSON.Serialization = JSON . StandardSerialization () ) =
135137 JSONRPCEndpoint (
136138 pipe_in,
137139 pipe_out,
@@ -143,7 +145,8 @@ JSONRPCEndpoint(pipe_in, pipe_out, err_handler = nothing) =
143145 err_handler,
144146 :idle ,
145147 nothing ,
146- nothing )
148+ nothing ,
149+ serialization)
147150
148151function write_transport_layer (stream, response)
149152 response_utf8 = transcode (UInt8, response)
@@ -290,7 +293,7 @@ function send_notification(x::JSONRPCEndpoint, method::AbstractString, params)
290293
291294 message = Dict (" jsonrpc" => " 2.0" , " method" => method, " params" => params)
292295
293- message_json = JSON. json ( message)
296+ message_json = sprint ( JSON. show_json, x . serialization, message)
294297
295298 put! (x. out_msg_queue, message_json)
296299
@@ -306,7 +309,7 @@ function send_request(x::JSONRPCEndpoint, method::AbstractString, params)
306309 response_channel = Channel {Any} (1 )
307310 x. outstanding_requests[id] = response_channel
308311
309- message_json = JSON. json ( message)
312+ message_json = sprint ( JSON. show_json, x . serialization, message)
310313
311314 put! (x. out_msg_queue, message_json)
312315
@@ -355,7 +358,7 @@ function send_success_response(endpoint, original_request::Request, result)
355358
356359 response = Dict (" jsonrpc" => " 2.0" , " id" => original_request. id, " result" => result)
357360
358- response_json = JSON. json ( response)
361+ response_json = sprint ( JSON. show_json, endpoint . serialization, response)
359362
360363 put! (endpoint. out_msg_queue, response_json)
361364end
@@ -369,7 +372,7 @@ function send_error_response(endpoint, original_request::Request, code, message,
369372
370373 response = Dict (" jsonrpc" => " 2.0" , " id" => original_request. id, " error" => Dict (" code" => code, " message" => message, " data" => data))
371374
372- response_json = JSON. json ( response)
375+ response_json = sprint ( JSON. show_json, endpoint . serialization, response)
373376
374377 put! (endpoint. out_msg_queue, response_json)
375378end
0 commit comments