I was wondering if there is a “correct” way to parse a JSON file using Jackson where the JSON file contains a property that is huge without loading the entire stream into memory. I need to keep the memory low since it’s an Android app. Am not asking here how to Android: Parsing large JSON file but rather one property is really large and the others don’t matter.
For instance, let’s say i have the following :
{
"filename": "afilename.jpg",
"data": "**Huge data here, about 20Mb base64 string**",
"mime": "mimeType",
"otherProperties": "..."
}
The data property could be extracted to a new file if needed (via an outputstream or other meanings) but i don’t manage to achieve this using Jackson. Am open to use other libraries i just thought jackson would be ideal thanks to it’s streaming API.
Thanks
Finally I manage to recover my huge data like this, where
inis an inputstream over the json file i want to parse the data from andoutis the file where am gonna write my data to:It’s not pretty, but works like a charm! @staxman let me know what you think.
Edit :
This is now an implemented feature , see : https://github.com/FasterXML/jackson-core/issues/14
and JsonParser.readBinaryValue()