@@ -412,20 +412,43 @@ public void testValueUpdateVanillaUntyped() throws Exception
412412 Map <String , Object > map = new LinkedHashMap <>();
413413 map .put ("a" , 42 );
414414
415+ // First update Map with JSON Object
415416 ObjectReader r = MAPPER .readerFor (Object .class ).withValueToUpdate (map );
416- Object result = r .readValue (a2q ("{'b' : 57}" ));
417+ Object result ;
418+
419+ result = r .readValue (a2q ("{'b': 0.25, 'c': [] }" ));
417420 assertSame (map , result );
418- assertEquals (2 , map .size ());
419- assertEquals (Integer .valueOf (57 ), map .get ("b" ));
421+ assertEquals (3 , map .size ());
422+ assertEquals (0.25 , map .get ("b" ));
423+ assertEquals (List .of (), map .get ("c" ));
420424
421- // Try same with other types, too
425+ // Then List with Array
422426 List <Object > list = new ArrayList <>();
423427 list .add (1 );
424428 r = MAPPER .readerFor (Object .class ).withValueToUpdate (list );
425- result = r .readValue ("[ 2, true ]" );
429+ result = r .readValue ("[ true, -0.5, { } ]" );
426430 assertSame (list , result );
427- assertEquals (3 , list .size ());
428- assertEquals (Boolean .TRUE , list .get (2 ));
431+ assertEquals (List .of (1 , true , -0.5 , Map .of ()), result );
432+
433+ // Then mismatches: Map with JSON Array
434+ r = MAPPER .readerFor (Object .class )
435+ .withValueToUpdate (map );
436+ result = r .readValue ("[ 42, -0.25, false, null ]" );
437+ List <Object > exp = new ArrayList <>();
438+ exp .add (42 );
439+ exp .add (-0.25 );
440+ exp .add (false );
441+ exp .add (null );
442+ assertEquals (exp , result );
443+
444+ // And then List with JSON Object
445+ r = MAPPER .readerFor (Object .class )
446+ .withValueToUpdate (new ArrayList <>());
447+ map .clear ();
448+ map .put ("a" , 0.5 );
449+ map .put ("b" , null );
450+ result = r .readValue (a2q ("{'a': 0.5, 'b': null}" ));
451+ assertEquals (map , result );
429452 }
430453
431454 @ Test
@@ -574,37 +597,16 @@ public void testPolymorphicUntypedCustom() throws IOException
574597 @ Test
575598 public void testEmptyArrayAndObject () throws Exception
576599 {
577- // Empty array
578- Object result = MAPPER .readValue ("[]" , Object .class );
579- assertNotNull (result );
580- assertTrue (result instanceof List );
581- assertEquals (0 , ((List <?>) result ).size ());
582-
583- // Empty object
584- result = MAPPER .readValue ("{}" , Object .class );
585- assertNotNull (result );
586- assertTrue (result instanceof Map );
587- assertEquals (0 , ((Map <?,?>) result ).size ());
600+ assertEquals (List .of (), MAPPER .readValue ("[]" , Object .class ));
601+ assertEquals (Map .of (), MAPPER .readValue ("{}" , Object .class ));
588602 }
589603
590604 @ Test
591605 public void testSingleElementArrayAndObject () throws Exception
592606 {
593- // Single element array
594- Object result = MAPPER .readValue ("[42]" , Object .class );
595- assertNotNull (result );
596- assertTrue (result instanceof List );
597- List <?> list = (List <?>) result ;
598- assertEquals (1 , list .size ());
599- assertEquals (Integer .valueOf (42 ), list .get (0 ));
600-
601- // Single property object
602- result = MAPPER .readValue ("{\" key\" :\" value\" }" , Object .class );
603- assertNotNull (result );
604- assertTrue (result instanceof Map );
605- Map <?,?> map = (Map <?,?>) result ;
606- assertEquals (1 , map .size ());
607- assertEquals ("value" , map .get ("key" ));
607+ assertEquals (List .of (42 ), MAPPER .readValue ("[42]" , Object .class ));
608+ assertEquals (Map .of ("key" , true ),
609+ MAPPER .readValue ("{\" key\" : true}" , Object .class ));
608610 }
609611
610612 @ Test
@@ -623,7 +625,6 @@ public void testFloatDeserializationWithBigDecimal() throws Exception
623625 @ Test
624626 public void testFloatTypesFloat32AndFloat64 () throws Exception
625627 {
626- // Test Float (32-bit)
627628 Object result = MAPPER .readValue ("1.5" , Object .class );
628629 assertTrue (result instanceof Double );
629630 result = MAPPER .readValue ("2.718281828" , Object .class );
0 commit comments