You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varcontent=await response.Content.ReadAsStringAsync().ConfigureAwait(false);returnglobal::Newtonsoft.Json.JsonConvert.DeserializeObject<...>(content)??thrownewglobal::System.InvalidOperationException("Response deserialization failed for
This avoids multiple copy and conversion operations and continues the async pattern.
(Buffer construction [eg. stream buffer grown to fit then copied to single solid buffer], UTF-16 char copying conversion into string, then deserialization converting UTF-16 into various types.)
This would add a dependency on MS's System.Text.Json package.
Support goes down to .NET Standard 2.0.
The text was updated successfully, but these errors were encountered:
yes, I agree with this. I didn't implement this as the default solution because the current solution allows for much easier debugging when the server sends something other than the expected json. in this case, an exception is completely uninformative.
Ideally I would implement your suggestion, but so that there are no problems with debugging
Instead of this,
Always read as a stream async and feed into
JsonSerializer.DeserializeAsync<TValue>
.This avoids multiple copy and conversion operations and continues the async pattern.
(Buffer construction [eg. stream buffer grown to fit then copied to single solid buffer], UTF-16 char copying conversion into string, then deserialization converting UTF-16 into various types.)
This would add a dependency on MS's System.Text.Json package.
Support goes down to .NET Standard 2.0.
The text was updated successfully, but these errors were encountered: