I have a JSON containing a binary property with a very large value:
{
"NormalStringValue" : "test",
"NormalIntValue" : 1,
"LargeBinaryValueInBase64": "AQB...."
}
The standard JsonTextReader.ReadAsBytes reads the value of a LargeBinaryProperty at once so a large byte array is allocated. I want to avoid this. For XmlTextReader there is a ReadContentAsBase64(byte[] buffer, int offset, int count) method which can perform buffered reading of a BASE64 content.
Is it possible to implement such a functionality for JsonTextReader?
Hello!
Maybe someone could give a hint on how to implement it myself?
I don't see any extension points in JsonTextReader which are suitable for this.
I have the same need. I don't know what developers who create such APIs (which return blobs in JSON) have in their minds, but I have to work with that, so streamed property value reading is a must have. However, I would advocate for a Stream-typed read result instead of reading in chunks into a buffer.
Most helpful comment
I have the same need. I don't know what developers who create such APIs (which return blobs in JSON) have in their minds, but I have to work with that, so streamed property value reading is a must have. However, I would advocate for a Stream-typed read result instead of reading in chunks into a buffer.