-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Increase serialization max size or make it user driven for SystemTextJson #61089
Comments
Tagging subscribers to this area: @dotnet/area-system-text-json Issue DetailsBackground and motivationI'm trying to serialize a big pdf of around 200MB, while trying to do so I'm getting following error: I found out that current size limitation for that is 125MB. That is definitely too little. I'd make sense to inscrease the cap, possibly to 2GB(like string that contains base64 of pdf or post request) or simply make that user defined. If I'm missing any solution to that problem, I'd appreciate some tips, API Proposalnamespace System.Collections.Generic
{
public class MyFancyCollection<T> : IEnumerable<T>
{
public void Fancy(T item);
}
} API Usage// Fancy the value
var c = new MyFancyCollection<int>();
c.Fancy(42);
// Getting the values out
foreach (var v in c)
Console.WriteLine(v); Alternative DesignsNo response RisksNo response
|
This appears to be by design: runtime/src/libraries/System.Text.Json/src/System/Text/Json/JsonConstants.cs Lines 71 to 78 in c690d27
Basically the restriction is in place in order to guarantee that the escaped token does fit in a single span segment. That being said, the constant seems to be derived from the rather pessimistic assumption that every single character in the input string needs escaping, in the worst expansion possible. I wonder if delaying the check until after we have detected that the string needs escaping might make sense here: Lines 82 to 96 in 4e7cf80
|
Not a solution, but maybe a workaround, if you need to serialize the pdf for Elasticsearch ingest pipelines, you can also use CBOR to send the data, instead of json. |
Avoid the size limit for the application state discovered at #18: Instead of packaging the JSON in a string, use the JSON directly on the interface to transport to the JS engine. For further discussion of the serializer limit in System.Text.Json, see dotnet/runtime#39953 and dotnet/runtime#61089
Background and motivation
I'm trying to serialize a big pdf of around 200MB, while trying to do so I'm getting following error:
I found out that current size limitation for that is 125MB. That is definitely too little. I'd make sense to inscrease the cap, possibly to 2GB(like string that contains base64 of pdf or post request) or simply make that user defined.
If I'm missing any solution to that problem, I'd appreciate some tips,
Thanks!
The text was updated successfully, but these errors were encountered: