internal static AppRoleAssignmentListResult DeserializeAppRoleAssignmentListResult(JsonElement element)
        {
            Optional <IReadOnlyList <AppRoleAssignment> > value = default;
            Optional <string> odataNextLink = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <AppRoleAssignment> array = new List <AppRoleAssignment>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(AppRoleAssignment.DeserializeAppRoleAssignment(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("odata.nextLink"))
                {
                    odataNextLink = property.Value.GetString();
                    continue;
                }
            }
            return(new AppRoleAssignmentListResult(Optional.ToList(value), odataNextLink.Value));
        }
        internal static DirectoryObject DeserializeDirectoryObject(JsonElement element)
        {
            if (element.TryGetProperty("objectType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "AppRoleAssignment": return(AppRoleAssignment.DeserializeAppRoleAssignment(element));

                case "Application": return(Application.DeserializeApplication(element));

                case "Group": return(ADGroup.DeserializeADGroup(element));

                case "ServicePrincipal": return(ServicePrincipal.DeserializeServicePrincipal(element));

                case "User": return(User.DeserializeUser(element));
                }
            }
            Optional <string>                    objectId                       = default;
            string                               objectType                     = default;
            Optional <DateTimeOffset?>           deletionTimestamp              = default;
            IReadOnlyDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>          additionalPropertiesDictionary = new Dictionary <string, object>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("objectId"))
                {
                    objectId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("objectType"))
                {
                    objectType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("deletionTimestamp"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        deletionTimestamp = null;
                        continue;
                    }
                    deletionTimestamp = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new DirectoryObject(objectId.Value, objectType, Optional.ToNullable(deletionTimestamp), additionalProperties));
        }