Expand my Community achievements bar.

SOLVED

Exporting Component values as JSON

Avatar

Level 2

We tried to export component values using @Model(adaptables = Resource.class, resourceType = {
"/components/content/carousel" }, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL, cache = false)
@exporter(name = "jackson", extensions = "json", options = {
@ExporterOption(name = "SerializationFeature.WRITE_DATES_AS_TIMESTAMPS", value = "true")}) to a JSON format, however we are able to see the JSON values in author and publisher instances, but on dispatcher URL when we try to access this JSON, it is giving us the content as html format.

How to access this JSON values from dispatcher URL as JSON format.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@HariniVR  how are you accessing the URL in author and publisher. Is it as part of selector?

 

If yes then use below filter rules to allow model json 

/0101 { /type "allow" /extension "json" /selectors "model" /path "/content/*" }

View solution in original post

4 Replies

Avatar

Community Advisor

Hi,

I would suggest to refer one of the core component it would be working with dispatcher as well and follow the similar steps.

 

Regards

Ankur

Avatar

Correct answer by
Community Advisor

@HariniVR  how are you accessing the URL in author and publisher. Is it as part of selector?

 

If yes then use below filter rules to allow model json 

/0101 { /type "allow" /extension "json" /selectors "model" /path "/content/*" }

Avatar

Community Advisor

Hello @HariniVR ,

Would you have URL examples that you could possibly share and/or screenshots from your test? You can mask out sensitive info.

Also, when you at it, can you also share the screenshot of the network request from the browser's dev tools?

 

thanks,

Preetpal

Avatar

Administrator

@HariniVR 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