Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

How to Export JSON (Business Logic) of multiple components in a page using Sling Model Exporter

Avatar

Avatar
Validate 1
Level 1
mayanky56670501
Level 1

Like

1 like

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
mayanky56670501
Level 1

Like

1 like

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
mayanky56670501
Level 1

05-12-2018

I am not able export JSON of multiple components in a page using Sling Model Exporter.

If I am using http://localhost:4502/content/test.model.json, then I am getting the simple json of the Page.

If I am using http://localhost:4502/content/test.infinity.json then I am getting the Deep level JSON for all the Node Content.

I basically want to get the JSON for my business logic developed in JAVA, that to be of multiple components lying on the page.

Using @Exporter Annotation. I am able to get the JSON for Individual Component, but I am not able to get that JSON for multiple components.

Would be grateful if anyone could provide the correct solution!

Replies

Avatar

Avatar
Validate 1
Level 1
mayanky56670501
Level 1

Like

1 like

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile

Avatar
Validate 1
Level 1
mayanky56670501
Level 1

Like

1 like

Total Posts

13 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Boost 1
View profile
mayanky56670501
Level 1

05-12-2018

I got your point that Sling Model Exporter is just 1-1 based on a given component. but If I want to export the JSON for multiple components specially the Business Logic, So Can you suggest me an API which converts the Sling Node to JSON output.

I mean to say if I can use that API to manually generate the JSON for a given resource path!!

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

05-12-2018

Yes, I checked again its 1-1 for given component, so we can't do /content/page.model.json

You can create servlet with your own selector and simply make a request with model selector to include json response of components inside your servlet. This will probably reduce the code overhead.

Avatar

Avatar
Validate 1
Level 2
susmithasama8
Level 2

Likes

2 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 1
View profile

Avatar
Validate 1
Level 2
susmithasama8
Level 2

Likes

2 likes

Total Posts

27 posts

Correct Reply

0 solutions
Top badges earned
Validate 1
Ignite 1
Give Back 3
Give Back
Boost 1
View profile
susmithasama8
Level 2

03-06-2019

Hi Arun Patidar​,

I also have the similar requirement. Can you please help me to understand the solution that you mentioned above.

I also have a site with several pages and each page has 1 or more content fragments on it + some othercomponents.

Now when i request the page ad model.json, I want to hide/remove the unwanted data from my json. How can i achieve this?

Can you please guide me on this?

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,279 likes

Total Posts

3,155 posts

Correct Reply

889 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

04-06-2019

Hi,

You have to parse again or you need to write your own solution which would convert node data to json.