-
Notifications
You must be signed in to change notification settings - Fork 76
Per [#106] added allowNullFields to provide the option of processing… #107
Per [#106] added allowNullFields to provide the option of processing… #107
Conversation
…ocessing null elements of lists as empty fields or the nullCharacter during serialization instead of the default behavior which skips null elements.
Thank you for the improvement here -- I will have to spend bit more time to fully understand it, but I think it looks like a good thing to add. In the meantime: if I have not yet asked for the Contributor License Agreement (CLA), from: https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf I would need one before merging the first contribution; one is enough for all future contributions. |
Thank you for looking at it. The paperwork is no problem. |
One question here: it seems like there are two different cases; "root nulls", where the main-level value is null; and "field nulls", where object property is null. Well, actually I guess there could be third one for nulls within array values (within field), but I'll ignore that for now. Should handling between these differ? It seems like the second case -- null as property value -- should be enabled by default (unless I misunderstand the effects) or at least vary independently from the question of whether to ignore root-level nulls? If so, it would seem that perhaps field-null handling should relate to schema (as it is per-type), whereas root-null handling should perhaps be a I am just thinking out aloud here and it is possible I miss something, or misunderstood things, so feel free to correct me if so. :) I'll keep on reading code and especially test case to have bit more understanding. And thanks for the CLA, received it. |
Those are good points. I hope this response isn’t too long-winded, but I am rethinking Your breakdown of the problem into two different cases provided helpful insight, and I am thinking hard about this point in particular regarding the second case of field nulls:
Here is a quick code snippet to help clarify the discussion:
I am thinking of Below I describe two sub-cases of the case you named Sub-Case 1: Field Nulls on rowItem POJO When the Sub-Case 2: Field Nulls on rowItem Lists When the Consistent Default Behavior I suppose right now the behavior when serializing a To be consistent, the List element null values should not be skipped by default for elements of Main-Level Null Case Referring back to the Unfortunately, my proposed Achieving the desired behavior can be ambiguous in some cases. For example, when a Next Steps I should probably close this PR and rework the code so that:
If you generally agree, I will go ahead and close this PR and reopen after I figure out a solution that meets the above goals. |
I revisited the code with our conversation in mind and found a simpler solution that only impacts the CsvGenerator. I will close this PR and open a new one with just that commit. |
Fix #106 null elements of lists as empty fields or the nullCharacter during serialization instead of the default behavior which skips null elements.