How do I get the values of this JSON object?

Timon Bosch 0 Reputation points
2023-12-29T14:28:39.99+00:00

I'm currently working with the following expression to fill a custom attribute:

AppRoleAssignmentsComplex([appRoleAssignments])		

This returns the following JSON Object(s):

{"id":"b150cbeb-172a-40e8-9fad-d44cad6a6a64","value":"sp_basic","displayName":"sp_basic"}, {"id":"ef56c4ed-8297-43a5-81df-ed16f51f347f","value":"test","displayName":"sp_rep_inc"}

I only need the values (sp_basic and sp_rep_inc). I cannot, for the life of me figure, out which expression to use.

Microsoft Security | Microsoft Entra | Microsoft Entra ID
Microsoft Security | Microsoft Entra | Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. James Hamil 27,226 Reputation points Microsoft Employee Moderator
    2023-12-30T00:11:53.5533333+00:00

    Hi @Timon Bosch , please try the following:

    To extract only the values from the JSON object, you can use the following expression:

    AppRoleAssignmentsComplex([appRoleAssignments]).value
    

    This expression will return an array of values from the JSON object. If you want to get a specific value from the array, you can use the following expression:

    AppRoleAssignmentsComplex([appRoleAssignments])[0].value
    

    This expression will return the first value from the array. If you want to get the second value, you can replace [0] with [1].

    Please let me know if you have any questions and I can help you further.

    If this answer helps you please mark "Accept Answer" so other users can reference it.

    Thank you,

    James


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.