Open BRLN1 opened 2 years ago
Tagging subscribers to this area: @dotnet/area-system-text-json See info in area-owners.md if you want to be subscribed.
Author: | BRLN1 |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-System.Text.Json`, `untriaged` |
Milestone: | - |
This appears to be by design: https://github.com/dotnet/runtime/blob/c690d2731db85933e8b4ab936fa71cd190471194/src/libraries/System.Text.Json/src/System/Text/Json/JsonConstants.cs#L71-L78 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: https://github.com/dotnet/runtime/blob/4e7cf804c0c89d4316bbe3327ff4fe4441ee953d/src/libraries/System.Text.Json/src/System/Text/Json/Writer/Utf8JsonWriter.WriteValues.String.cs#L82-L96
cc @ahsonkhan @bartonjs @krwq
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.
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!