File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,10 @@ func (w *removingWalker) doList(t *schema.List) (errs ValidationErrors) {
5858 defer w .allocator .Free (l )
5959 // If list is null or empty just return
6060 if l == nil || l .Length () == 0 {
61+ // For extraction, we just return the value as is (which is nil or empty). For extraction the difference matters.
62+ if w .shouldExtract {
63+ w .out = w .value .Unstructured ()
64+ }
6165 return nil
6266 }
6367
@@ -113,6 +117,10 @@ func (w *removingWalker) doMap(t *schema.Map) ValidationErrors {
113117 }
114118 // If map is null or empty just return
115119 if m == nil || m .Empty () {
120+ // For extraction, we just return the value as is (which is nil or empty). For extraction the difference matters.
121+ if w .shouldExtract {
122+ w .out = w .value .Unstructured ()
123+ }
116124 return nil
117125 }
118126
Original file line number Diff line number Diff line change @@ -675,6 +675,38 @@ var removeCases = []removeTestCase{{
675675 ),
676676 `{"mapOfMapsRecursive":{"a":{"b":null}}}` ,
677677 `{"mapOfMapsRecursive": {"a":{"b":{"c":null}}}}` ,
678+ }, {
679+ // empty list
680+ `{"listOfLists": []}` ,
681+ _NS (
682+ _P ("listOfLists" ),
683+ ),
684+ `` ,
685+ `{"listOfLists": []}` ,
686+ }, {
687+ // null list
688+ `{"listOfLists": null}` ,
689+ _NS (
690+ _P ("listOfLists" ),
691+ ),
692+ `` ,
693+ `{"listOfLists": null}` ,
694+ }, {
695+ // empty map
696+ `{"mapOfMaps": {}}` ,
697+ _NS (
698+ _P ("mapOfMaps" ),
699+ ),
700+ `` ,
701+ `{"mapOfMaps": {}}` ,
702+ }, {
703+ // nil map
704+ `{"mapOfMaps": null}` ,
705+ _NS (
706+ _P ("mapOfMaps" ),
707+ ),
708+ `` ,
709+ `{"mapOfMaps": null}` ,
678710 }},
679711}}
680712
You can’t perform that action at this time.
0 commit comments