jakartaee / jsonb-api

Jakarta JSON Binding
https://eclipse-ee4j.github.io/jsonb-api/
Other
79 stars 39 forks source link

Support getter-only list. #334

Open onacit opened 2 years ago

onacit commented 2 years ago

Apologies whenever this issue is not appropriate.

May I have a chance of deserializing a collection field using a getter only?


public List<Some> getSome() { // JAXB used to work with this.
    if (some == null) {
        some = new ArrayList<>();
    }
    return some;
}

//public void setSome(List<Some> some) {
//    this.some = some;
//}

private List<Some> some;

Thank you.

rmannibucau commented 2 years ago

+1, we have a flag in johnzon for that (feature is named "use getter as writer" for collections). There are a few cases it makes sense - often when reusing jaxb model as mentionned.