Skip to content

Unexpected results calling deserialize with TypeLiteral #92

@ukchucktown

Description

@ukchucktown

I have the following invocation:
JsonIterator.deserialize(results, new TypeLiteral<CollectionResponse<Feed>>(){})

My result was a List with a HashMap when what I want is a List of Feed objects. I'm ignoring most of the JSON, I'm only interested in 3 properties. I included the JSON I'm trying to parse. This is my first attempt at using TypeLiteral so I may be doing something incorrectly.

{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": "f560fccb-4020-43c1-8a27-92507ef625bd",
"search_terms": [
"gigi hadid"
],
"owner": "...",
"egress_nodes": [
"DE"
],
"status": "ACTIVE",
"expires_at": null,
"available_sources": [
"92c784ae-b7bf-4434-a6cc-740109d91cc8"
],
"available_egress_nodes": [
"DE"
],
"created_at": "2017-07-27T13:29:20.935108Z",
"name": "Test",
"description": "",
"start_date": null,
"end_date": null,
"match_all_include": false,
"velocity": 0.0666666666666667,
"storage_consumption": 0.000011026778,
"consumption": 0.000120833333333333,
"persistence_enabled": true,
"sources": [
"92c784ae-b7bf-4434-a6cc-740109d91cc8"
],
"permissions": {
"has_read_access": true,
"has_write_access": true,
"has_share_access": true,
"has_ownership": true
}
}
]
}

public class CollectionResponse<T> {
private List<T> results;

public List<T> getResults() {
    return results;
}

}

public class Feed {
private String id;
private String owner;
private String name;

public String getId() {
    return id;
}

public String getOwner() {
    return owner;
}

public String getName() {
    return name;
}

}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions