Am struck in a problem please let me know if you have any idea how to proceed on this.
I have a method myMethod(Map<String, Object> inputData) this Object can be a String/PrimitiveWrapper/Map/Collection i.e List/Vector. I need to get the values from this Object in the format given below.
If the Object is a Map. If it’s a simple Map its fine but this one is a complex Map. This Map can contain any type of data.
Suppose if it contains the data as shown below:
I need to iterate the eight Map i.e in backward direction and values should be read as below. The big question is how do I know what is there in the Object. As this Object can contain any data structure.
Description of the above values: Customers is the key of eight map that contains seven
Customer is the key of seven that contains a list six so it should be index form Customer, Customer
fiveA is part of six at index 0,
Addresses is the key of fiveA, that contains Map four
Address is the key of four that contains a list three, so it should be index for Address, Address.
AddressLine1 is the key of one and has value House 1
so the final value from the top looks like this:
Now I need to get the values in the above way and put the same in another map.
There will be no XML data as input, only it will be of the form myMethod(Map<String, Object> inputData) and this Object can be a String/PrimitiveWrapper/Map/Collection i.e List/Vector. Now the inputData I have to process is: myMethod(Map<String, Object> eight)
But here I cant create any class, how will I know what is the input Map data. The values Customers, Customer, Addresses, .... are Map Key values. There might be something in java how to read such type of data. The one which I have shown is the sample. The same map can contain extra data also.
I cannot create a Customer class. Am getting the data from the third party and I need to process through that data and get the values. I get the data in the format HashMap<String, Object> only. I have no idea what is present in the Map. I just need to iterate and get the data.
How do you get the data? Is it sent to you through a socket connection or something? When you're done reading the data, what's going to happen to it? Are you going to process it yourself, does it get delegated to third party classes?
Rauf Khan wrote:I cannot create a Customer class. Am getting the data from the third party
Rauf , for integrating your system with a thirdparty system, the first thing you need is a contract defining how these two systems are going communicate each other and what should be the structure of the data.. This is true even in case you are just using just thirdparty library- there the contract may just an API exposed by the thirdparty library... Are you saying that you don't this information with you ? If so thats not a very encouraging situation ...
Am developing a component which will be place in the application as a JAR. The application will call my method and pass input data in format (Map<String, Object> inputData)and i need to process this data.
I got the first break through to get the values but still couldnt get the output as expected. Can anyone please help me out to get the exact output.