Exposing a multifield component as json | Community
Skip to main content
vladd57498318
New Participant
Oct 10, 2019 9:36 PM UTC

Exposing a multifield component as json

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:

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.

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

3 replies

vladd57498318
New Participant
Oct 11, 2019 7:10 AM UTC

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

Translate
Ankur_Khare
New Participant
Oct 11, 2019 3:41 AM UTC

You need to customize it as per your requirement.

Translate
Employee
Oct 10, 2019 11:07 PM UTC

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 ?

Translate