> For the complete documentation index, see [llms.txt](https://bernardo.gitbook.io/development-docs-java/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://bernardo.gitbook.io/development-docs-java/jackson/object-hierarchy.md).

# Object Hierarchy

## JsonTypeInfo

Used to handle inheritance and polymorphic classes.

```java
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.PROPERTY, property = "className")
public class Employee

public class ExtendedEmployee extends Employee
```

Now the ExtendedEmployee can be serialized and deserialized using Employee as a reference. Jackson will know the actual type of Employee to use.

### JsonSubTypes

Used along JsonTypeInfo to indicate the inheritance hierarchy.

```java
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "type")
@JsonSubTypes({
   @Type(value = EmployeeExtended.class, name = "extended"),
   @Type(value = EmployeeAdvanced.class, name = "advanced")
})
public class Employee
```
