Saviynt unveils its cutting-edge Intelligence Suite products to revolutionize Identity Security!
Click HERE to see how Saviynt Intelligence is transforming the industry.
Saviynt Copilot Icon

how to access an attribute value from a JSON String?

pahm
New Contributor III
New Contributor III

Hello,

If I have a user customproperty stored a very long string that is a JSON formatted data structure such as {"myAttrName1":"MyAttrValue1", "myAttrName2":"MyAttrValue2"}

When I create an account, I need get the attribute value from this customproperty. what is the easy way to traverse and access an attribute value from the String using groovy scripting allowed in Saviynt?

Such as user?.customproperty?.myAttrName2?.trim()

if no direct access allowed, what is the best way to convert this String to JSON Map and access from the Map?

Thanks

2 REPLIES 2

sudeshjaiswal
Saviynt Employee
Saviynt Employee

Hello @pahm ,

We are checking on it we will keep you posted.

Thanks.

If you find the above response useful, Kindly Mark it as "Accept As Solution".

Hello @pahm,

You may need to write to query like below, depending on your use case.

${user?.customproperty != null && user?.customproperty != '' ? new groovy.json.JsonSlurper().parseText(user.customproperty)?.myAttrName2?.trim() ?: 'Default Value' : 'Default Value'}

 Thank,

If you find the above response useful, Kindly Mark it as "Accept As Solution".