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

I18n json as API

Avatar

Avatar
Level 1
sagarneelb
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile

Avatar
Level 1
sagarneelb
Level 1

Likes

0 likes

Total Posts

3 posts

Correct Reply

0 solutions
View profile
sagarneelb
Level 1

09-09-2020

Hi,

I am trying to build a API on top of i18n. So I can expose it for other channels to consume it. Essentially, I don't want to expose the full json dict. 

I want something like this, <domain>/<country>/<lang>/<pagecode>/<feature>.json and expecting it to give me the filtered json for the feature. I could do it for .html. which is giving me the json (as string) in the Html output. But when I use .json it is not. I have a json rendition (json.jsp). It is Getting handled by default servlet and giving me error. Please help. I checked .json extension is there in the sling get servlet. 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 250
MVP
ChitraMadan
MVP

Likes

271 likes

Total Posts

165 posts

Correct Reply

67 solutions
Top badges earned
Boost 250
Establish
Ignite 1
Give Back 5
Give Back 3
View profile

Avatar
Boost 250
MVP
ChitraMadan
MVP

Likes

271 likes

Total Posts

165 posts

Correct Reply

67 solutions
Top badges earned
Boost 250
Establish
Ignite 1
Give Back 5
Give Back 3
View profile
ChitraMadan
MVP

09-09-2020

Hi @sagarneelb ,

 

You can have a custom servlet based on resource type or selector e.g.

You can call<domain>/<country>/<lang>/<pagecode>/<feature>.jsondict

 

@Component(metatype = false)
@Service(Servlet.class)
@Properties({
@Property(name = "sling.servlet.selectors", value = { "jsondict" }) })
public class DefaultDictionarySelector extends SlingSafeMethodsServlet {
////// Filter logic based on feature
///// Write json
}

 

Answers (2)

Answers (2)

Avatar

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

232 likes

Total Posts

294 posts

Correct Reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile

Avatar
Springboard
MVP
Shashi_Mulugu
MVP

Likes

232 likes

Total Posts

294 posts

Correct Reply

67 solutions
Top badges earned
Springboard
Bedrock
Validate 1
Applaud 100
Establish
View profile
Shashi_Mulugu
MVP

09-09-2020

@sagarneelb can you please create a resource type servlet with extension JSOn and try please?

Avatar

Avatar
Ignite 1
Employee
aemmarc
Employee

Likes

184 likes

Total Posts

243 posts

Correct Reply

92 solutions
Top badges earned
Ignite 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Ignite 1
Employee
aemmarc
Employee

Likes

184 likes

Total Posts

243 posts

Correct Reply

92 solutions
Top badges earned
Ignite 1
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
aemmarc
Employee

09-09-2020

If the JSON request is being handled by org.apache.sling.servlets.get.DefaultGetServlet -- then why not set enable.json to false?