Reputation: 5084
I am trying to retrieve the profilePicture parameter in the LinkedIn liteProfile response. However, for some reason, they return two json objects with the same parameter name (Who even built this API?!).
Response:
{
"firstName": {
"localized": {
"en_US": "Damien"
},
"preferredLocale": {
"country": "US",
"language": "en"
}
},
"lastName": {
"localized": {
"en_US": "Roger"
},
"preferredLocale": {
"country": "US",
"language": "en"
}
},
"profilePicture": {
"displayImage": "urn:li:digitalmediaAsset:C5103AQEGbbhK9i7Qhw",
"displayImage~": {
"paging": {
"count": 10,
"start": 0,
"links": []
},
"elements": [
{
"identifiers": [
{
"identifier": "https://media.licdn.com/dms/image/C5103AQEGbbhK9i7Qhw/profile-displayphoto-shrink_200_200.....",
....
}
}
]
}
}
}
As you may have noticed, in profilePicture
, there's two params called displayImage
. One with a ~
. How do I access this from a java pojo class?
My class looks like this:
public class LinkedInProfileResponse {
public FirstName firstName;
public LastName lastName;
public ProfilePicture profilePicture;
public String id;
public class ProfilePicture {
public String displayImage;
public DisplayImage displayImage;
}
}
Upvotes: 0
Views: 99
Reputation: 11474
The @SerializedName
annotation can be used on a field in your POJO to specify the name of the JSON attribute to be mapped to the Java field.
So in your case:
...
@SerializedName("displayImage~)
public DisplayImage displayImage;
...
Upvotes: 2