'Read chunked HTTP request in Java

We have a GET API request that returns a very large JSON.

Is there any way to read chunks of that JSON in java spring boot via restTemplate?



Solution 1:[1]

No, you need an JSON api for that. If you don't have a api for that you simply can't anything with your large JSON. You you can download a simple JSON api here: https://github.com/fangyidong/json-simple . There you can parse ur very large JSON into a JsonObject with final JSONObject obj = (JSONObject) new JSONParser().parse(ur big json string). If you want to read chunks of the JSON you can use the obj.get(key) method.

Example: Your JSON is: {test:"test1"}

final JSONObject obj = (JSONObject) new JSONParser().parse("{test:\"test1\"}");

obj.get("test"); It will return test1.

If I made any misteak then correct me.

Edit: I understand it now. You could just remove parts of the Json by using obj.remove(key) and your json shouldn't be that big

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1