// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

// <auto-generated/>

#nullable disable

using System.Collections.Generic;
using System.Text.Json;
using Azure.Core;

namespace Azure.ResourceManager.Resources.Models
{
    internal partial class ResourceListResult
    {
        internal static ResourceListResult DeserializeResourceListResult(JsonElement element)
        {
            Optional<IReadOnlyList<GenericResourceExpanded>> value = default;
            Optional<string> nextLink = default;
            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List<GenericResourceExpanded> array = new List<GenericResourceExpanded>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(GenericResourceExpanded.DeserializeGenericResourceExpanded(item));
                    }
                    value = array;
                    continue;
                }
                if (property.NameEquals("nextLink"))
                {
                    nextLink = property.Value.GetString();
                    continue;
                }
            }
            return new ResourceListResult(Optional.ToList(value), nextLink.Value);
        }
    }
}
