cancel
Showing results for 
Search instead for 
Did you mean: 

Issues Converting ResultSet to Java Object

Issues Converting ResultSet to Java Object

Hi,

 

I am calling the API to return a list of Contacts.I can successfully get the list back, however I am having trouble coverting the elements of the List to a Contact Object in Java. The internal elements of the list are LinkedHashMap.

 

ResultSet<Contact> rsContact = restTemplate.getForObject("https://api.constantcontact.com/v2/contacts?status=ALL&limit=50&api_key=<API_KEY&access_token="<toke...>", ResultSet.class);

 

The LinkedHashMap cannot be converted to a Contact object directly, so I tried using an ObjectMapper for the conversion. this threw an exception, indicating there was a field named "field" in the CustomField object that could not be mapped.

 

ObjectMapper mapper = new ObjectMapper();

List<Contact> pojos = mapper.convertValue(list, new TypeReference<List<Contact>>() { });//[conversion of Linkedhashmap][1]

 

I then tried to map by calling a method on the Component object. Again, the list elements returned are LinkedHashMaps, not a Contact object.

 

List<Contact> lstContacts = Component.listFromJSON(strContactJSON, Contact.class);

Contact cccc = lstContacts.get(0);

 

If you decompose the LinkedHashMap, the Contact data is there, but I just cannot get it mapped to a Contact object.

 

Any help would be greatly appreciated. If you want to reply directly, please use email ==> 

 

Thanks,

 

Dave Crout

 

1 REPLY 1
Moderator

Re: Issues Converting ResultSet to Java Object

Hello @Justice_and_Peace. I see that you already posted this same question in our Developer board. They are best suited to help you there with any API questions that you have. We will reach out to that team so you are sure to get a reply. 


Caitlin M.
Community & Social Media Support

Did I answer your question? If so, please mark my post as an "Accepted Solution" by clicking the Accept as Solution button in the bottom right hand corner of this post.

You're not alone on your email marketing journey. Connect with a Marketing Advisor to see how they can help you develop the right strategy for your business and get the most out of your Constant Contact experience.