jakartaee / jakartaee/jsonb-api

Configure impl to interface mappings

Open
#65 14 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
95
Forks
41
Avg merge
1d 6h
Merged PRs (30d)
35

Description

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.

Contributor guide

Open the contributing guide

Research direction

Start with JsonbConfig and the JsonbBuilder.create configuration entry point, then trace jsonb.fromJson(json, Customer.class) for interface instantiation, including the nested Address type. Done means the documented or implemented configuration can map the interfaces to their concrete implementations without changing the provided model classes.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.