Hi,
I need to write a service to fetch the node properties from page component and get the JSON response .Please guide me or suggest me some reference .
thanks
Solved! Go to Solution.
Views
Replies
Total Likes
Hey @Varun,
Here are the docs which could help you.
https://docs.adobe.com/docs/en/aem/6-0/develop/components/pageinfo.html
https://helpx.adobe.com/experience-manager/using/first-osgi.html
https://helpx.adobe.com/experience-manager/using/using-jsonwriter-objects-display-cq.html
Jitendra
Views
Replies
Total Likes
Hi,
Learn here how you can create service in AEM: https://helpx.adobe.com/experience-manager/using/first-osgi.html
Use method in your service: https://sling.apache.org/apidocs/sling6/org/apache/sling/commons/json/jcr/JsonJcrNode.html#JsonJcrNo...)
Its will convert node properties to JSON data
Thanks
Views
Replies
Total Likes
Hi
Here are some of ways to get JCR values,
Link:- https://helpx.adobe.com/experience-manager/using/programmatically-accessing-cq-content-using.html
Link:- https://docs.adobe.com/docs/en/cq/5-6-1/dam/customizing_and_extendingcq5dam/query_builder.html
Link:- https://helpx.adobe.com/experience-manager/using/jqom.html
Link:- https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html
Note:- Its not json response. What is the need of json response? Can you elaborate the use case ?
You can convert this response to JSON, by JSONObjest (Java Code ot generate JSON)
Link:- http://stackoverflow.com/questions/18983185/how-to-create-correct-jsonarray-in-java-using-jsonobject
//
import org.json.simple.JSONObject;class JsonEncodeDemo {public static void main(String[] args){JSONObject obj = new JSONObject();obj.put("name", "foo");obj.put("num", new Integer(100));obj.put("balance", new Double(1000.21));obj.put("is_vip", new Boolean(true));System.out.print(obj);}}
Link:- http://www.tutorialspoint.com/json/json_java_example.htm
I hope this would help you.
Thanks and Regards
Kautuk Sahni
Views
Replies
Total Likes
Also, to get Json as a response, you can use QueryBuilder.
Eg.
Go to:- http://localhost:4502//libs/cq/search/content/querydebug.html
Write any query...
type=rep:User
path=/home/users
nodename=*
p.limit=10
JSON QueryBuilder Link will create a link, which would return JSON as a response.
~kautuk Sahni
Views
Replies
Total Likes
Hey @Varun,
Here are the docs which could help you.
https://docs.adobe.com/docs/en/aem/6-0/develop/components/pageinfo.html
https://helpx.adobe.com/experience-manager/using/first-osgi.html
https://helpx.adobe.com/experience-manager/using/using-jsonwriter-objects-display-cq.html
Jitendra
Views
Replies
Total Likes
thanks
Views
Replies
Total Likes
thanks for all the references, Its working fine , I need to do the same thing in mobile app, shall I use the same API(code ) for mobile app also or is there any difference mobile API for this requirement.
thanks
Views
Replies
Total Likes
Varun,
I think, there should not be an issue using this API in mobile APP. Are you having any doubt it?
Hi Jitendra,
Actually I am using AEM as a backend in my application( mobile app), and sending json response from AEM to WCS server, and this application will run as an APP on mobile device,my doubt is only I haven't tested it on mobile thts why I have doubt these API will work in mobile APP or not.
Regards,
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Replies
Total Likes
Hi,
why don't you use the default servlets?
kind regards,
Jörg
Views
Replies
Total Likes
Views
Likes
Replies