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

Exposing a multifield component as json

Avatar

Avatar
Ignite 1
Level 1
vladd57498318
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile

Avatar
Ignite 1
Level 1
vladd57498318
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile
vladd57498318
Level 1

10-10-2019

Hi,

I'm faced with a problem where I need to expose a multifield component as json in a specific way. When accessing the url of the component.model.tidy.json the json I currently get is like this:

Screenshot 2019-10-11 at 00.31.26.png

What I would like to do is to eliminate the "jcr:primaryType":"nt:unstructured" from every property but I found no way to do it without creating my custom exporter.

Here is my java class:

import org.apache.sling.api.resource.Resource;
import org.apache.sling.models.annotations.Exporter;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.Optional;

import javax.inject.Inject;

@Exporter(name = "jackson", extensions = "json")

@Model(adaptables = Resource.class, resourceType = "/apps/wcax-core/components/content/abs-generic-list/v1/abs-generic-list")

public class AbsGenericList {

   @Inject
  @Optional
   private Resource genericlist;

  public Resource getGenericlist() { return this.genericlist; }

}

If anyone has any idea on how to get rid of that property it would be of great help.

Replies

Avatar

Avatar
Contributor
Employee
hamidk92094312
Employee

Likes

102 likes

Total Posts

240 posts

Correct Reply

38 solutions
Top badges earned
Contributor
Shape 1
Ignite 1
Give Back 50
Give Back 5
View profile

Avatar
Contributor
Employee
hamidk92094312
Employee

Likes

102 likes

Total Posts

240 posts

Correct Reply

38 solutions
Top badges earned
Contributor
Shape 1
Ignite 1
Give Back 50
Give Back 5
View profile
hamidk92094312
Employee

10-10-2019

Do you want to process the json output to eliminate the repeating property or you want to get the json output without the repeating property at the first place ?

Avatar

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

152 likes

Total Posts

363 posts

Correct Reply

56 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile

Avatar
Ignite 1
MVP
Ankur_Khare
MVP

Likes

152 likes

Total Posts

363 posts

Correct Reply

56 solutions
Top badges earned
Ignite 1
Validate 10
Validate 1
Give Back 50
Give Back 5
View profile
Ankur_Khare
MVP

10-10-2019

You need to customize it as per your requirement.

Avatar

Avatar
Ignite 1
Level 1
vladd57498318
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile

Avatar
Ignite 1
Level 1
vladd57498318
Level 1

Likes

0 likes

Total Posts

2 posts

Correct Reply

0 solutions
Top badges earned
Ignite 1
Give Back
View profile
vladd57498318
Level 1

11-10-2019

Ideally, I would want to get the json output without the repeating property.