Parse a nested json file | Community
Skip to main content
rk39193348
New Participant
April 11, 2016
Solved

Parse a nested json file

  • April 11, 2016
  • 5 replies
  • 2057 views

Hi ,

I want to parse a nested json file , using sightly and java / javascript. How can i achieve this ? Please let me know

 

Regards

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by kautuk_sahni

Hi 

As mentioned by Scott,

You can parse JSON the same way you would do for a non-AEM project - you can use JavaScript.

Git :- https://helpx.adobe.com/experience-manager/using/restful-services.html

//parse.js 

 

Community article:- https://helpx.adobe.com/experience-manager/using/using-jsonwriter-objects-display-cq.html

                             https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html            

// This article uses a JSONWriter instance to pass data to the web client

 

Example:- http://jsfiddle.net/5pjha/

I hope this would of some help to you.

Thanks and Regards

Kautuk Sahni

5 replies

kautuk_sahni
kautuk_sahniAccepted solution
Employee
April 18, 2016

Hi 

As mentioned by Scott,

You can parse JSON the same way you would do for a non-AEM project - you can use JavaScript.

Git :- https://helpx.adobe.com/experience-manager/using/restful-services.html

//parse.js 

 

Community article:- https://helpx.adobe.com/experience-manager/using/using-jsonwriter-objects-display-cq.html

                             https://helpx.adobe.com/experience-manager/using/custom-sling-servlets.html            

// This article uses a JSONWriter instance to pass data to the web client

 

Example:- http://jsfiddle.net/5pjha/

I hope this would of some help to you.

Thanks and Regards

Kautuk Sahni

Kautuk Sahni
smacdonald2008
New Participant
April 14, 2016

You parse JSON the same way you would in a non-AEM project - you can use JavaScript. I pointed you to some examples using JQeury, 

rk39193348
New Participant
April 12, 2016

edubey wrote...

How are you getting JSON and where?

As per parsing you cannot do in component html file but can be done easily in javascript use api file.

But share more details.

 

 

JSON file is present in my component.  I am creating a new file inside component called new.json. Please let me know how to parse

smacdonald2008
New Participant
April 11, 2016

You can use JQuery to parse JSON:

https://api.jquery.com/jQuery.parseJSON/

See this community as an example: 

https://helpx.adobe.com/experience-manager/using/restful-services.html

Notice in this example - the backend service returns JSON. 

edubey
New Participant
April 11, 2016

How are you getting JSON and where?

As per parsing you cannot do in component html file but can be done easily in javascript use api file.

But share more details.