How can we share a block like header or a complete page built on Edge Delivery Services [using Universal Editor] as JSON to third party/other channels.
Solved! Go to Solution.
Hi @pardeepg4829047 ,
You can't, EDS does not support page to json. however you can expose content in plain text using .plain selector.
You can use AEM and write a sling model JSON exporter. DO not use servlet as it will have security concern over 3rd part app.
Hi @pardeepg4829047,
I agree with @NirbhayAEMBee - using a Sling Model with a JSON exporter is the preferred and secure way to expose AEM content (like headers or full pages) as JSON, especially when third-party consumption is involved. I completely agree with your approach to avoid servlets, as they introduce unnecessary security and maintenance overhead.
Annotate it with @Exporter
for JSON output:
@Model(adaptables = Resource.class, adapters = HeaderModel.class, resourceType = "your/components/header", defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
@Exporter(name = "jackson", extensions = "json")
Once the model is in place, access your JSON like:
Do not expose servlets or unsecured APIs.
Use AEM permission-based access control or allow read-only access to specific endpoints via dispatcher/CDN rules.
Optionally apply CSRF token or signed URLs if consumed by authenticated systems.
Hope that helps!
Views
Replies
Total Likes
Hi @pardeepg4829047 ,
If you’ve built a header, footer, or even a full page using Edge Delivery Services (EDS) in AEM, and you want to share that content as JSON with another system like a mobile app or external service here’s how to do it the right way.
No servlets. No unnecessary complexity. Just clean, secure, maintainable AEM code.
Step 1: Create a Sling Model for Your Component
Let’s say you want to expose a header block. Start by creating a Sling Model for it.
@Model(
adaptables = Resource.class,
resourceType = "yourproject/components/header",
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
)
@Exporter(
name = "jackson",
extensions = "json"
)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class HeaderModel {
@Inject
private String logo;
@Inject
private String navLink1;
@Inject
private String navLink2;
public String getLogo() {
return logo;
}
public String getNavLink1() {
return navLink1;
}
public String getNavLink2() {
return navLink2;
}
}
This model pulls values like logo and nav links from the component’s dialog or content node.
Step 2: Access the JSON
Once deployed, you can hit the model like this:
https://publish.my-aem-site.com/content/mysite/us/en/_jcr_content/root/header.model.json
This will return a clean JSON object representing your component data.
You can also export an entire page this way (as long as all child components are Sling Model-enabled):
https://publish.my-aem-site.com/content/mysite/us/en/page.model.json
Step 3: Secure the Endpoint
Since you're exposing data over the internet, make sure it's secure.
- Dispatcher Rules: Only allow .model.json for specific, known paths
- Permissions: Restrict access to just what's needed. If the endpoint is public, only allow anonymous read on safe content.
- Optional: Add token-based access or signed URLs if needed by your architecture.
Example dispatcher rule:
/0001 {
/type "allow"
/glob "/content/mysite/us/en/_jcr_content/root/header.model.json"
}
Regards,
Amit
Views
Replies
Total Likes
Hi @pardeepg4829047 ,
You can't, EDS does not support page to json. however you can expose content in plain text using .plain selector.
Hi @pardeepg4829047,
I hope the response shared above helped address your question. If it did, it would be wonderful if you could mark it as "correct reply"— this helps others in the community find helpful solutions more easily.
If you’re still facing any challenges, please feel free to continue the conversation here. We’re happy to support further.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies