0
votes

I have a zip file containing multiple json files. I have unzipped them then got POJO object from json using below code:

reader = new BufferedReader(new FileReader(file));
Gson gson = new GsonBuilder().create();
Element[] people = gson.fromJson(reader, Element[].class);

but I need to process these json files one by one using spring batch. Can someone help me how I can achieve this in spring batch and I want to read json file using chunk of 1000 My json object is very complex. Example:

{
    "students": {
      "subelements": {
          "dep": {
            "data": [
              "XYZ"
            ]
          }
        }
      }
}
1
What represents an item in this file? Which fragment corresponds to the Element class? - Mahmoud Ben Hassine
Element is main class which holds id, type and list of properties - R.Henderson
elements is list of items ( "elements": { }) - R.Henderson

1 Answers

1
votes

Your data structure is not one of the types you could handle with Spring Batch out-of-the-box. See more details here: https://stackoverflow.com/a/51933062/5019386.

So I think in your case, you would need to create a custom item reader to parse a specific fragment of your input file.