Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

Loading JSON Content into AEM | AEM Community Blog Seeding




Loading JSON Content into AEM by perficient


Let’s talk about extract, transform, and load, also known as ETL. If you are an AEM professional, this is something you have previously dealt with. It could be something along the lines of products, user bios, or store locations.

The extract and transform parts may differ depending on your source and requirements. The loading part is almost always going to be into AEM. While there may be a few ways to do that, let us talk about what is there for you out-of-the-box.

Sling Post Servlet
As an AEM developer, the Sling Post Servlet is something you should be familiar with. In particular, there is an import operation. This allows us to do the following:

curl -L https://www.boredapi.com/api/activity | \
curl -u admin:admin \
-F":contentFile=@-" \
-F":nameHint=activity" \
-F":operation=import" \
-F":contentType=json" \
You can run this many times. You will get activity_* nodes under /content/mysite/us/en/jcr:content/root/container. This assumes that the source is already in the format you desire. Meaning you have already done the transform part.

And the import operation can deal with more complex JSON structures, even XML. Here is a possible output that could be provided by a transform:

"jcr:primaryType": "cq:Page",
"jcr:content": {
"jcr:primaryType": "cq:PageContent",
"jcr:title": "My Page",
"sling:resourceType": "mysite/components/page",
"cq:template": "/conf/mysite/settings/wcm/templates/page-content",
"root": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "mysite/components/container",
"layout": "responsiveGrid",
"container": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "mysite/components/container"
Save this to a file named mypage.json and run the following curl command.

Read Full Blog

Loading JSON Content into AEM


Please use this thread to ask the related questions.

Kautuk Sahni
0 Replies