Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5955061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:03:37+00:00 2026-05-22T18:03:37+00:00

I have the following JSON I am receiving from a REST call: socialConnectionsData :

  • 0

I have the following JSON I am receiving from a REST call:

"socialConnectionsData" : {
  "friends" : [ {
    "friend" : {
      "firstname" : "John",
      "lastname" : "Doe"
     }
    }]
}

My current class looks like this:

public class SocialConnectionsData {
private List<Friend> friends;

public List<Friend> getFriends() {
    return friends;
}

public void setFriends(List<Friend> friends) {
    this.friends = friends;
}    
}

However, I get an Jackson exception stating that “friend” is an unrecognized field. How would I have a collection of Friends and maintain the type of Friend?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T18:03:38+00:00Added an answer on May 22, 2026 at 6:03 pm

    Looks to me like you have an extra property name in there. Jackson is expecting JSON like this to correspond to your Objects:

    "socialConnectionsData" : {
      "friends" : [ {
          "firstname" : "John",
          "lastname" : "Doe"
        }]
    }
    

    You shouldn’t need to do anything to maintain the type of Friend because your list is declared with that as a generic parameter.

    If you want to go the other way around and make your objects match the JSON, then you’ll need an extra level of indirection like so:

    public class SocialConnectionsData {
        private List<FriendWrapper> friends;
    
        public List<FriendWrapper> getFriends() {
            return friends;
        }
    
        public void setFriends(List<FriendWrapper> friends) {
            this.friends = friends;
        }    
    }
    
    public class FriendWrapper {
        private Friend friend;
    
        public Friend getFriend() {
            return friend;
        }
    
        public void setFriend(Friend friend) {
            this.friend = friend;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following JSON string returned to a page. {firstName:Bob,lastName:Gates,department:Tech} I would like to
I have the following JSON string (from wikipedia http://en.wikipedia.org/wiki/JSON ) { name:Product, properties: {
I have the following json returned to me from an API. sections: { 1:
I have the following JSON coming back from a web service which I am
I have a struts action receiving following JSON: { commandId:tC, id:123, def: } Following
I have the following json output when i call a sample webservice <string>[{Name:Ajay Singh,Company:Birlasoft
say I have the following json object; {'fname':'john', 'lname':'Locke'} and the following text boxes
All, I have the following JSON Request that comes through a function call in
I have the following situation: My webservice is receiving JSON data and creating models
I have the following json output from a webservice: [ { subCategories: [ {

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.