keycloak JWT token contain "\" when mapping multivalued json array attribute

52 views Asked by At

I have assign a client scope for my client with a mapper which is multivalued. For example "school"

In the user, I create attribute as follow:

school: {"student_No":"1000","teacher_No":"50","male":"800","female":"250"}

school: {"student_No":"2000","teacher_No":"100","male":"1600","female":"500"}

However when I obtain JWT access token, the payload show this after decode using JWT.io:

"school": [

" {\"student_No\":\"1000\",\"teacher_No\":\"50\",\"male\":\"800\",\"female\":\"250\"}",

"{\"student_No\":\"2000\",\"teacher_No\":\"100\",\"male\":\"1600\",\"female\":\"500\"}"

]

I found "\" is added within the array. I don't know why it is generated, how can it be removed in the JTW?

1

There are 1 answers

0
Volodymyr On

Check your mapper config carefully. It seems that Keycloak stores your JSON as a string and then returns it to the client