Using Multiple Selectors

Although not a standard use case, it is possible to configure multiple selectors in addition to the model selector.

https://<server>:<port>/content/page.model.selector1.selector2.json

However in such a case the model selector must be the first selector and the extension must be .json.

Annotate the Sling Model Interface

To be taken into account by the JSON Exporter framework, the Model interface should implement the ComponentExporter interface (or ContainerExporter, if there is a container component).

The corresponding Sling Model interface ( MyComponent) would be then annotated using Jackson annotations to define how it should be exported (serialized).

The Model interface must be properly annotated to define which methods should be serialized. By default, all methods that respect the usual naming convention for getters is serialized and derives their JSON property names naturally from the getter names. This can be prevented or overridden using @JsonIgnore or @JsonProperty to rename the JSON property.

Example

The Core Components have supported JSON export since release 1.1.0 of the core components and can be used as a reference.

For an example, see the Sling Model implementation of the Image Core Component and its annotated interface.

CODE ON GITHUB

You can find the code of this page on GitHub

Experience Manager


The True Cost of a Failed Implementation

Online | Session | General Audience

A failed implementation isn’t just an inconvenience — it costs real revenue. Poor execution and misaligned tools disrupt pipelines,...

Wed, Mar 19, 2:00 PM PDT (9:00 PM UTC)

Register

Put the Customer at the Center and Build Relationships That Last a Lifetime

Online | Strategy Keynote | General Audience

First impressions last a lifetime. Great first impressions feel personal, connected, and relevant right from the start. From the first...

Wed, Mar 19, 2:30 PM PDT (9:30 PM UTC)

Register

Connect with Experience League at Summit!

Get front-row access to top sessions, hands-on activities, and networking—wherever you are!

Learn more