My requirement is to read Huge Json from REST API call and process, i googled a lot to find out a feasible solution, everyone saying use JsonReader bypassing InputStream.I am doing the same but still encountered out of memory.
I am using gson library to get the data, I am not sure how to achieve this functionality, could you please guide me on this. small json response, this is working fine and fast whereas getting huge response stream I am getting out of Memory.
public void processHugeInputStream(InputStream is){
BufferedReader br = new BufferedReader(new InputStreamReader(is));
String line;
List<Sample> list = new ArrayList<Sample>();
while(line = br.readLine()!=null){
Reader stringReader = new StringReader(line);
JSONReader reader = new JSONReader(stringReader);
reader.setLinent(true);
Sample object = gson.fromJSON(reader,Sample.class);
list.add(object);
}
}