Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu
Online

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.845 Beiträge
 
Delphi 12 Athens
 
#8

AW: Anzahl Einträge in JsonArray

  Alt 20. Sep 2024, 08:50
Delphi-Quellcode:
for i := 0 to JSonArray.Count - 1 do
begin
  JsonValue := TJsonValue.ParseJSONValue(st);
  if (JSONValue is TJSONArray) then
    id := ((JSONValue as TJSONArray).Items[i] as TJSonObject).Get('id').JSONValue.Value;

  name := ((JSONValue as TJSONArray).Items[i] as TJSonObject).Get('name').JSONValue.Value;
  stringgrid1.Cells[1,j] := id;
Delphi-Quellcode:
for i := 0 to JSonArray.Count - 1 do
begin
  JsonValue := TJsonValue.ParseJSONValue(st);
  if (JSONValue is TJSONArray) then
  begin
    id := ((JSONValue as TJSONArray).Items[i] as TJSonObject).Get('id').JSONValue.Value;
    name := ((JSONValue as TJSONArray).Items[i] as TJSonObject).Get('name').JSONValue.Value;
    stringgrid1.Cells[1,j] := id;
  end;
Was fällt dir auf?


Delphi-Quellcode:
for i := 0 to JSonArray.Count - 1 do
begin
  JsonValue := TJsonValue.ParseJSONValue(st);
  try
    if (JSONValue is TJSONArray) then
    begin
      id := ((JSONValue as TJSONArray).Items[i] as TJSonObject).Get('id').JSONValue.Value;
      name := ((JSONValue as TJSONArray).Items[i] as TJSonObject).Get('name').JSONValue.Value;
      stringgrid1.Cells[1,j] := id;
    end;
  finally
    JsonValue.Free;
  end;
Tipp: Füge mal ein ReportMemoryLeaksOnShutdown := True; in deine DPR oder ins OnCreate deiner Form ein.




Anzahl = Count
Bereich = 0 bis Anzahl-1 oder 1 bis Anzahl

10 = 0 bis 9 (0 1 2 3 4 5 6 7 8 9 = 10 Zahlen)
oder
10 = 1 bis 10 (1 2 3 4 5 6 7 8 9 10 = auch 10 Zahlen)
wenn bei 1 begonnen wird zu zählen

oder
10 = 99998 bis 100007
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests

Geändert von himitsu (20. Sep 2024 um 09:04 Uhr)
  Mit Zitat antworten Zitat