I am trying to convert the large JSON/JSON-LD file to XML. The JSON file will contain a list of events (not all events are the same and each may have different information/data). I would like to read the events one by one and store the information in a single Object (rather than having different objects for each event). I would like to store it in the form of Parent and Children. As soon as I read one event I would like to convert it to JSON then go to the next one.
I am looking into JACKSON and seems like it fits this. However, I am looking into this particular class TokenBuffer which is actually kind of doing the same. It's reading the JSON file line by line and then trying to see if the incoming element is Array or Object based on that it's making various decisions.
I wanted to confirm if I can use this Class directly to pass my JsonFile and get the Parent and child relationship which will be stored in JsonWriteContext
later I can convert it to XML.
Basically, my sample file will have many events in the JSON which I would like to read one by one and then get the element info and its parent-children relationship in a Single Object such as maybe HashMap
.
After trying some of the things following is my code which will contain the Parent and Child elements from Json:
The above is the context file that will store the information. Below is the JSON parser file.