title | description | date | ms.date | author | ms.author |
---|---|---|---|---|---|
Use Utf8JsonWriter |
A guide on how to improve performance using Utf8JsonWriter. |
2024-01-23 |
1/23/2024 |
habbes |
clhabins |
Applies To:[!INCLUDEappliesto-webapi][!INCLUDEappliesto-webapi][!INCLUDEappliesto-odatalib]
The OData core library implements a wrapper on top of the Utf8JsonWriter
to complement the default JSON writer. This writer offers better performance and fewer memory allocations compared to using the JSON writer that's used by default in Microsoft.OData.Core
.
To enable Utf8JsonWriter
, check out any of the following guides depending on the library you are using in your application:
- Enable
Ut8fJsonWriter
when usingMicrosoft.OData.Core
library directly - Enable
Utf8JsonWriter
when usingMicrosoft.AspNetCore.OData
8.x library - Enable
Ut8fJsonWriter
when usingMicrosoft.AspNetCore.OData
7.x library
When using Utf8JsonWriter
, consider using the UnsafeRelaxedJsonEscaping
encoder to perform escaping as described here. This encoder is more relaxed and escapes fewer characters. This can improve performance over the default encoder which escapes more characters. Frequent escaping of large strings may result in additional performance and memory overhead.