Possible Method to trim the json model generated in AEM SPA | Community
Skip to main content
akashkriz005
Level 2
February 20, 2023
Solved

Possible Method to trim the json model generated in AEM SPA

  • February 20, 2023
  • 1 reply
  • 900 views

Hello everyone ! 

We were trying to implement AEM SPA using react and consuming the model.json generated to display the data to another applications. While consuming the model.json there are some json data being coming up from the page level , which we need to trim and display only the components authored in the page. Any possible method for this approach ? 

 

Also for example if we check the json response for the text component 

 

Is it possible to edit  " :type: "  to type , without the semicolon ? Or is this a default configuration ?

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 Prince_Shivhare

Interesting question,

I am also working on JSON generated SPA model. so there are two ways -

1. I was able to ignore it using below code in class level.

@JsonIgnoreProperties(":type")

and create a property called type and inside the getter of type just return the resourceType of model class.

2. Override the getExportedType() in your model class.

@Override
@JsonProperty("type")
public String getExportedType() {}

some more annotation if you wanna try:

https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations

 

Cheers!

 

1 reply

Prince_Shivhare
Community Advisor
Prince_ShivhareCommunity AdvisorAccepted solution
Community Advisor
February 20, 2023

Interesting question,

I am also working on JSON generated SPA model. so there are two ways -

1. I was able to ignore it using below code in class level.

@JsonIgnoreProperties(":type")

and create a property called type and inside the getter of type just return the resourceType of model class.

2. Override the getExportedType() in your model class.

@Override
@JsonProperty("type")
public String getExportedType() {}

some more annotation if you wanna try:

https://github.com/FasterXML/jackson-annotations/wiki/Jackson-Annotations

 

Cheers!