Actually, I think we will get more answers moving the discussion to Github discussions. WDYT?
On Sat, Oct 19, 2024 at 2:00 AM [email protected] <[email protected]> wrote: > Perhaps Tatu can have a look? > > On Friday, October 18, 2024 at 11:53:37 AM UTC+3 Joo Hyuk Kim wrote: > >> Your implementation Does not seem too off , But not sure :/ >> >> 2024년 10월 18일 (금) 오후 4:06, [email protected] <[email protected]>님이 작성: >> >>> So @JsonMerge is not appropriate here? >>> >>> On Friday, October 18, 2024 at 1:47:07 AM UTC+3 Joo Hyuk Kim wrote: >>> >>>> > Jackson should not create any list. >>>> >>>> To be more specific, You do not want to create any list and ur looking >>>> for a such feature. >>>> >>>> What we can do here is write a custom deserializer to do such thing >>>> and there is already plenty references on the web >>>> >>>> 2024년 10월 18일 (금) 오전 4:04, [email protected] <[email protected]>님이 작성: >>>> >>>>> My class contains an initialized custom collection >>>>> >>>>> class MyClass { >>>>> >>>>> MyList<Integer> myList = MyList.create(); >>>>> } >>>>> >>>>> where MyList is a j.u.List. When deserializing, I get an exception >>>>> saying that there is no known deserializer for MyList ("Cannot find a >>>>> deserializer for non-concrete List type"), which is generally >>>>> understandable, but I already initialized it, so there's no need for one. >>>>> Instead, I just want to add the items to the list. >>>>> To demonstrate, I can add a private setter inside the class: >>>>> >>>>> private void setMyList(List<Integer> ints) { >>>>> ints.forEach(MyList::add); } >>>>> >>>>> this works, but I don't think it should be needed. Specifically, >>>>> Jackson should not create any list. It needs to deserialize the values of >>>>> the items anyway; then instead of creating a list, add them to the >>>>> existing >>>>> one. It's a List, so it should know to call 'add' ('put' for map). >>>>> >>>>> I know there is @JsonMerge, and I thought that that's what I needed, >>>>> but just adding it to the field doesn't work, I still get the same >>>>> exception. Am I not understanding @JsonMerge or am I doing something >>>>> wrong? >>>>> >>>>> Thanks! >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "jackson-user" group. >>>>> To unsubscribe from this group and stop receiving emails from it, send >>>>> an email to [email protected]. >>>>> To view this discussion on the web visit >>>>> https://groups.google.com/d/msgid/jackson-user/af74c8b0-1516-4cc8-9117-be6808cf9223n%40googlegroups.com >>>>> <https://groups.google.com/d/msgid/jackson-user/af74c8b0-1516-4cc8-9117-be6808cf9223n%40googlegroups.com?utm_medium=email&utm_source=footer> >>>>> . >>>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "jackson-user" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> >> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/jackson-user/4446a07a-f0b8-4bad-8442-3571d0a328d3n%40googlegroups.com >>> <https://groups.google.com/d/msgid/jackson-user/4446a07a-f0b8-4bad-8442-3571d0a328d3n%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> >> -- > You received this message because you are subscribed to the Google Groups > "jackson-user" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/jackson-user/66dc4a78-c343-42b0-85e5-77a78bb2f3bbn%40googlegroups.com > <https://groups.google.com/d/msgid/jackson-user/66dc4a78-c343-42b0-85e5-77a78bb2f3bbn%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "jackson-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jackson-user/CALS-ipzCLf_UkZZqZCJoUkV4f5gbHOHGjqnpGn1Wr%3DsmK%2Bm0sA%40mail.gmail.com.
