internal static GetInstancesPage DeserializeGetInstancesPage(JsonElement element)
        {
            Optional <IReadOnlyList <TimeSeriesInstance> > instances = default;
            Optional <string> continuationToken = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("instances"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TimeSeriesInstance> array = new List <TimeSeriesInstance>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TimeSeriesInstance.DeserializeTimeSeriesInstance(item));
                    }
                    instances = array;
                    continue;
                }
                if (property.NameEquals("continuationToken"))
                {
                    continuationToken = property.Value.GetString();
                    continue;
                }
            }
            return(new GetInstancesPage(continuationToken.Value, Optional.ToList(instances)));
        }
Beispiel #2
0
        internal static InstanceOrError DeserializeInstanceOrError(JsonElement element)
        {
            Optional <TimeSeriesInstance> instance = default;
            Optional <TsiErrorBody>       error    = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("instance"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    instance = TimeSeriesInstance.DeserializeTimeSeriesInstance(property.Value);
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = TsiErrorBody.DeserializeTsiErrorBody(property.Value);
                    continue;
                }
            }
            return(new InstanceOrError(instance.Value, error.Value));
        }