using Newtonsoft.Json.Linq;
using System.Collections.Generic;
// Deserialize the JSON string to a JObject
JObject jsonObject = JObject.Parse(Response_Users);
// Extract the array of users from the JSON object
JArray usersArray = (JArray)jsonObject[“users”];
// Create a list to hold the user data
var userList = new List();
for (int i = 0; i < usersArray.Count; i++)
{
JObject userObject = (JObject)usersArray[i];
userList.Add(new User
{
DisplayName = (string)userObject[“displayName”],
Mail = (string)userObject[“mail”],
Id = (string)userObject[“id”],
OnPremisesDistinguishedName = (string)userObject[“onPremisesDistinguishedName”]
});
}
// Define the User class
public class User
{
public string DisplayName { get; set; }
public string Mail { get; set; }
public string Id { get; set; }
public string OnPremisesDistinguishedName { get; set; }
}
Can anybody help.
I am coming from BluePrism where i would define classes in global code in the object editor, and the rest in a code Block.
Run a For Each loop for userData and inside that you can print the below values in Write Line
For Each item in userList
WriteLine -> item(0) → DisplayName
WriteLine -> item(1) → Mail
WriteLine -> item(2) → Id
WriteLine -> item(3) → OnPremisesDistinguishedName
End For Each