Skip to content

How to parse (nested) interfaces? How to map interfaces to concrete implementation? #65

Open
@jansupol

Description

@jansupol

I have a interface model like:

public interface Customer {

    String getName();
    Address getAddress();
}

public interface Address {

    String getStreet();
    String getCity();
}

For each interface there is a single implementation.
Important to note that the model contains nested properties/types using (again) interfaces.

How can this be parsed?

JsonbConfig config = new JsonbConfig()
// TODO: what configuration to add to map interfaces to concrete implementations?
Jsonb jsonb = JsonbBuilder.create(config)
jsonb.fromJson(json, Customer.class);

Above gives exception: javax.json.bind.JsonbException: interface com.acme.Customer not instantiable

Note: I cannot change the interfaces nor the concrete implementations as these are provided.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions