@@ -476,21 +476,21 @@ public void removeFieldsUsingRegexWithNullValue() {
476
476
477
477
final JsonObject objectToPatch = JsonFactory .newObjectBuilder ()
478
478
.set ("a" , JsonFactory .newObjectBuilder ()
479
- .set ("{{ / 2023-04-.*/ }}" , JsonValue .nullLiteral ())
479
+ .set ("{{ ~ 2023-04-.*~ }}" , JsonValue .nullLiteral ())
480
480
.set ("2023-05-01" , JsonValue .of ("new" ))
481
481
.set ("2023-05-02" , JsonValue .of ("catch" ))
482
482
.set ("2023-05-03" , JsonValue .of ("phrase" ))
483
483
.build ())
484
484
.set ("b" , JsonFactory .newObjectBuilder ()
485
- .set ("{{ / 2023-04-01/ }}" , JsonValue .nullLiteral ())
486
- .set ("{{ / ^2023-04-03$/ }}" , JsonValue .nullLiteral ())
487
- .set ("{{ / [0-9]{4}-04-.+4/ }}" , JsonValue .nullLiteral ())
485
+ .set ("{{ ~ 2023-04-01~ }}" , JsonValue .nullLiteral ())
486
+ .set ("{{ ~ ^2023-04-03$~ }}" , JsonValue .nullLiteral ())
487
+ .set ("{{ ~ [0-9]{4}-04-.+4~ }}" , JsonValue .nullLiteral ())
488
488
.set ("2023-05-01" , JsonValue .of ("new" ))
489
489
.set ("2023-05-02" , JsonValue .of ("catch" ))
490
490
.set ("2023-05-03" , JsonValue .of ("phrase" ))
491
491
.build ())
492
492
.set ("c" , JsonFactory .newObjectBuilder ()
493
- .set ("{{ /.*/ }}" , JsonValue .nullLiteral ())
493
+ .set ("{{ ~.*~ }}" , JsonValue .nullLiteral ())
494
494
.set ("2023-05-01" , JsonValue .of ("new" ))
495
495
.set ("2023-05-02" , JsonValue .of ("catch" ))
496
496
.set ("2023-05-03" , JsonValue .of ("phrase" ))
@@ -523,5 +523,50 @@ public void removeFieldsUsingRegexWithNullValue() {
523
523
Assertions .assertThat (mergedObject ).isEqualTo (expectedObject );
524
524
}
525
525
526
+ @ Test
527
+ public void removeFieldsUsingRegexWithNullValueWithHierarchy () {
528
+ final JsonObject originalObject = JsonFactory .newObjectBuilder ()
529
+ .set ("first" , JsonFactory .newObjectBuilder ()
530
+ .set ("second" , JsonFactory .newObjectBuilder ()
531
+ .set ("third" , JsonFactory .newObjectBuilder ()
532
+ .set ("something-on-third" , "foobar3" )
533
+ .set ("another-on-third" , false )
534
+ .build ())
535
+ .set ("something-on-second" , "foobar2" )
536
+ .set ("another-on-second" , false )
537
+ .build ())
538
+ .set ("something-on-first" , "foobar1" )
539
+ .set ("another-on-first" , 42 )
540
+ .build ()
541
+ )
542
+ .build ();
543
+
544
+ final JsonObject objectToPatch = JsonFactory .newObjectBuilder ()
545
+ .set ("first" , JsonFactory .newObjectBuilder ()
546
+ .set ("{{ ~seco.*~ }}" , JsonValue .nullLiteral ())
547
+ .set ("second" , JsonFactory .newObjectBuilder ()
548
+ .set ("another-on-second" , true )
549
+ .build ()
550
+ )
551
+ .build ()
552
+ )
553
+ .build ();
554
+
555
+ final JsonValue expectedObject = JsonFactory .newObjectBuilder ()
556
+ .set ("first" , JsonFactory .newObjectBuilder ()
557
+ .set ("second" , JsonFactory .newObjectBuilder ()
558
+ .set ("another-on-second" , true )
559
+ .build ())
560
+ .set ("something-on-first" , "foobar1" )
561
+ .set ("another-on-first" , 42 )
562
+ .build ()
563
+ )
564
+ .build ();
565
+
566
+ final JsonValue mergedObject = JsonMergePatch .of (objectToPatch ).applyOn (originalObject );
567
+
568
+ Assertions .assertThat (mergedObject ).isEqualTo (expectedObject );
569
+ }
570
+
526
571
527
572
}
0 commit comments