Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.

Loading JSON Content into AEM | AEM Community Blog Seeding

Avatar

Administrator

BlogImage.jpg

Loading JSON Content into AEM by perficient

Abstract

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" \
http://localhost:4502/content/mysite/us/en/jcr:content/root/container
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

Q&A

Please use this thread to ask the related questions.



Kautuk Sahni
0 Replies