Sling Model Exporter was introduced in Sling Models v1.3.0. This new feature allows new annotations to be added to Sling Models that define how the Model an can be exported as a different Java object, or more commonly, serialized into a different format such as JSON.
Sling Model Exporter is a feature of the Apache Sling Project and not directly bound to the AEM product release cycle. Sling Model Exporter is compatible with AEM versions:
AEM 6.3 and later
- No extra dependencies required
- Requires installation of
Enabling Exporter support on a Sling Model is as easy as adding the @Exporter annotation to the Java class.
For AEM 6.1 and AEM 6.2 projects, ensure the Sling Models 1.3.x API dependency is included ABOVE the AEM uber-jar dependency.
<!-- Put this above AEM 6.2 and lower Uber-Jar --> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.models.api</artifactId> <version>1.3.0</version> <scope>provided</scope> </dependency>
<plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-scr-plugin</artifactId> <version>1.23.0</version> </plugin>
Sling Model Exporter supports passing per-model Exporter options to the Exporter implementation to drive how the Sling Model is finally exported. These options generally apply "globally" to how the Sling Model is exported, versus per data point which can be done via inline annotations described below.
Jackson Exporter options include:
Exporters implementations may also support annotations that can be applied inline on the Sling Model class, that can provide a finer level of control how the data is exported.