Skip to content
This repository was archived by the owner on Jun 15, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public Object deserialize(JsonParser jp, DeserializationContext cxt) throws IOEx
// Json object this method is called to handle.
//
JsonNode currentJsonNode = mapper.readTree(jp);
if (currentJsonNode.isNull()) {
currentJsonNode = mapper.getNodeFactory().objectNode();
}
final Class<?> tClass = this.defaultDeserializer.handledType();
for (Class<?> c : TypeToken.of(tClass).getTypes().classes().rawTypes()) {
if (c.isAssignableFrom(Object.class)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,32 @@ public void canSerializeMapKeysWithDotAndSlash() throws Exception {
Assert.assertEquals("{\"teacher\":{\"students\":{\"af.B/D\":{},\"af.B/C\":{}}},\"tags\":{\"foo.aa\":\"bar\",\"x.y\":\"zz\"},\"properties\":{\"name\":\"school1\"}}", serialized);
}

/**
* Validates decoding and encoding of a type with type id containing dot and no additional properties
* For decoding and encoding base type will be used.
*
* @throws IOException
*/
@Test
public void canHandleTypeWithTypeIdContainingDotAndNoProperties() throws IOException {
JacksonAdapter adapter = new JacksonAdapter();

String rabbitSerialized = "{\"@odata.type\":\"#Favourite.Pet.RabbitWithTypeIdContainingDot\"}";
String shelterSerialized = "{\"properties\":{\"animalsInfo\":[{\"animal\":{\"@odata.type\":\"#Favourite.Pet.RabbitWithTypeIdContainingDot\"}},{\"animal\":{\"@odata.type\":\"#Favourite.Pet.RabbitWithTypeIdContainingDot\"}}]}}";

AnimalWithTypeIdContainingDot rabbitDeserialized = adapter.deserialize(rabbitSerialized, AnimalWithTypeIdContainingDot.class);
Assert.assertTrue(rabbitDeserialized instanceof RabbitWithTypeIdContainingDot);
Assert.assertNotNull(rabbitDeserialized);

AnimalShelter shelterDeserialized = adapter.deserialize(shelterSerialized, AnimalShelter.class);
Assert.assertTrue(shelterDeserialized instanceof AnimalShelter);
Assert.assertEquals(2, shelterDeserialized.animalsInfo().size());
for (FlattenableAnimalInfo animalInfo: shelterDeserialized.animalsInfo()) {
Assert.assertTrue(animalInfo.animal() instanceof RabbitWithTypeIdContainingDot);
Assert.assertNotNull(animalInfo.animal());
}
}

/**
* Validates that decoding and encoding of a type with type id containing dot and can be done.
* For decoding and encoding base type will be used.
Expand Down