diff --git a/tests/FSharp.Data.Benchmarks/JsonBenchmarks.fs b/tests/FSharp.Data.Benchmarks/JsonBenchmarks.fs index 4c1c7b168..337fc2f9f 100644 --- a/tests/FSharp.Data.Benchmarks/JsonBenchmarks.fs +++ b/tests/FSharp.Data.Benchmarks/JsonBenchmarks.fs @@ -69,14 +69,27 @@ type JsonConversionBenchmarks() = [] member this.AccessProperties() = - sampleJson.Properties() - |> Array.head - |> fun (_, value) -> value + match sampleJson with + | JsonValue.Array elements when elements.Length > 0 -> + // Get properties of the first issue in the GitHub issues array + elements.[0].Properties() + |> Array.head + |> fun (_, value) -> value + | JsonValue.Record _ -> + // Fallback for record-type JSON + sampleJson.Properties() + |> Array.head + |> fun (_, value) -> value + | _ -> JsonValue.Null [] member this.GetArrayElements() = match sampleJson with + | JsonValue.Array elements -> + // GitHub.json is an array of issues, return the array elements + elements | JsonValue.Record props -> + // Fallback: look for an "items" property match Array.tryFind (fun (k, _) -> k = "items") props with | Some (_, JsonValue.Array elements) -> elements | _ -> [||]