How to access data of nested objects in LinkedHashMap How to access data of nested objects in LinkedHashMap json json

How to access data of nested objects in LinkedHashMap


You should cast the contactObj to the class whose primitive you want to access. Ex, if your class for contactObj is Contact, then you should do:

Contact contactObj = (Contact) map.get("contacts");

and then you can access the methods/primitives in the class that are accessible from this point. Ex, say your class is like

Class Contact{String firstname;public String getFirstName(){  return this.firstname;   }}  

So, you can access the first name like as shown below:

contactObj.getFirstName();