Hi,
The out-of-the-box configuration for in browser query results show JSON data with p.guessTotal: 'success', 'results', 'total', 'more', 'offset':
{
"success":true,
"results":2,
"total":2,
"offset":0,
"hits":[
{
"jcr:path":"/content/path/to/articles/article-a",
"jcr:createdBy":"admin",
"jcr:created":"Tue Dec 03 2013 16:27:01 GMT-0500",
"jcr:primaryType":"cq:Page",
"jcr:content":{
"sling:resourceType":"path/to/components/global/page/productdetail",
"_comment":"// ***SNIP*** //",
"thumbnail":{
"jcr:lastModifiedBy":"admin",
"imageRotate":"0",
"jcr:lastModified":"Wed Dec 04 2013 12:10:47 GMT-0500",
"jcr:primaryType":"nt:unstructured"
}
}
},
{
"jcr:path":"/content/path/to/articles/article-1",
"jcr:createdBy":"admin",
"jcr:created":"Tue Dec 03 2013 16:26:51 GMT-0500",
"jcr:primaryType":"cq:Page",
"jcr:content":{
"sling:resourceType":"path/to/components/global/page/productdetail",
"_comment":"// ***SNIP*** //",
"thumbnail":{
"jcr:lastModifiedBy":"admin",
"imageRotate":"0",
"fileReference":"/content/dam/path/to/IBMDemo/apparel/women/wsh005_shoes/WSH005_0533_is_main.jpg",
"jcr:lastModified":"Mon Dec 09 2013 17:57:58 GMT-0500",
"jcr:primaryType":"nt:unstructured"
}
}
}
]
}
This is returned by running /bin/querybuilder.json?
I need the result JSON data to be API accessible, meaning show results without p.guessTotal: 'success', 'results', 'total', 'more', 'offset'. Result should be just the raw JSON data. I.E:
{
"jcr:path":"/content/path/to/articles/article-1",
"jcr:createdBy":"admin",
"jcr:created":"Tue Dec 03 2013 16:26:51 GMT-0500",
"jcr:primaryType":"cq:Page"
},
{
"jcr:path":"/content/path/to/articles/article-1/jcr:content",
"sling:resourceType":"myapp/components/global/page/productdetail",
"jcr:lockIsDeep":true,
"jcr:uuid":"4ddebe08-82e1-44e9-9197-4241dca65bdf",
"jcr:title":"Article 1",
"jcr:mixinTypes":[
"mix:lockable",
"mix:versionable"
],
"jcr:created":"Tue Dec 03 2013 16:26:51 GMT-0500",
"jcr:baseVersion":"24cabbda-1e56-4d37-bfba-d0d52aba1c00",
"cq:lastReplicationAction":"Activate",
"jcr:isCheckedOut":true,
"cq:template":"/apps/myapp/templates/global/productdetail",
"cq:lastModifiedBy":"admin",
"jcr:primaryType":"cq:PageContent",
"jcr:predecessors":[
"24cabbda-1e56-4d37-bfba-d0d52aba1c00"
],
"cq:tags":[
"mysite:mytag"
],
"jcr:createdBy":"admin",
"jcr:versionHistory":"9dcd41d4-2e10-4d52-b0c0-1ea20e102e68",
"cq:lastReplicatedBy":"admin",
"cq:lastModified":"Mon Dec 09 2013 17:57:59 GMT-0500",
"cq:lastReplicated":"Mon Dec 16 2013 11:42:54 GMT-0500",
"jcr:lockOwner":"admin"
}
What can I add to the query so that 'success', 'results', 'total', 'more', 'offset' isn't displayed? I need just the JSON data. I am referencing Query Builder API
Solved! Go to Solution.
Hi,
you can write a servlet which can be exposed as an API.
In your servlet, you can get the same json object but return only ‘hits’ object as the response
You can build a custom AEM Service that uses the QUeryBuilder API and get the result set you need. Then in you Java logic of your service - build the JSON to meet your needs. For example, use a JSON Java API:
JSON.simple example – Read and write JSON
How to convert Java object to / from JSON (Gson)
Now your AEM Service will return the JSON that meets your needs with the result set retrieved by using the QUeryBuilder in the JSON.
Views
Replies
Total Likes
Hi,
you can write a servlet which can be exposed as an API.
In your servlet, you can get the same json object but return only ‘hits’ object as the response
Thanks Lokesh for the correct response!
Views
Replies
Total Likes
Here is another good article that can help you -- Converting AEM/Sling Resources to JSON - Adobe Experience Manager | AEM/CQ | Apache Sling
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies