Expand my Community achievements bar.

Learn about Edge Delivery Services in upcoming GEM session

How to remove aem properties jcr:lastModifiedBy from model.json since we dont have in sling model

Avatar

Level 2

How we can remove it by overriding that properties ?

6 Replies

Avatar

Level 8

@pratikshah : How are you trying to access json for your component/page?

I am assuming you are just changing the extension to '.json'. Please correct me if that is not the case. With this, it will give all the properties that exists for your content such as jcr:lastModifiedBy. And this way of accessing content as json should not be allowed and would not work when you access it from dispatcher as all such json requests would be blocked.

If you have a sling model, then you should be doing sling model exporter. It will only return the properties which are defined as part of your component and has a getter method/field in your model. Please refer- https://medium.com/@toimrank/aem-sling-model-exporter-90dc872835b9

AEM documentation for the same- https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/develo...

thanks.

Avatar

Community Advisor

Hi @pratikshah 

 

Is there an exporter your sling model is extending, like ComponentExporter or ContainerExporter or some custom exporter? If your model is extending from some other model, it is possible that parent model must be exporting it. If this is the case, you can override the method and add @JsonIgnore annotation to exclude it from export. 

Avatar

Level 2

hey @Lokesh_Vajrala yes using the jackson exporter but that lastModifiedBy is not there in component right so how to remove it should I full in sling model class.

Avatar

Administrator

@pratikshah Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 2

hey @kautuk_sahni still havent found any correct answer still searching for it.

Avatar

Level 10

@pratikshah This can not be achieved through OOTB approach. please write custom exporter to have required keys.