can you please share your recommendation:
I am getting an XML in the below format from upstream system. I would like to convert into a JAVA POJO object. Since it is a key value pair,
1. Is it ok to use HashMap?
2. Is HashMap<String, Object> ok for this? since the value can again hold another name value pair? Is it a good practive to "Object" generic data type in Hashmap?
Some times the upstream can send additional name value pair, which we dont know. since we dont know all the possible keys of student class, can we use any other datastructure like HashMap<String, Object> ? The value here is Object type because emailList, phoneList is of object type but studId and Name are string type. Is there any other datastructure we can use since we dont know all the possible keys?
A HashMap (or any Map for that matter) wont help with repeated keys e.g. "emailID" is repeated in your structure above. Using a Object in generics type has a very limited usecase and I dont think that's applicable here.
Java already allows you to take an XML and convert it to a DOM : https://docs.oracle.com/javase/tutorial/jaxp/dom/readingXML.html
Considering all the data is String, you can come up with your own structure like this :
I'm also curious, if you are not aware of the keys/structure, what is your intention after making the Java POJO ?