Einzelnen Beitrag anzeigen

Benutzerbild von Gloegg_FHBI
Gloegg_FHBI

Registriert seit: 28. Nov 2006
Ort: Neuss
46 Beiträge
 
Delphi 10 Seattle Professional
 
#6

AW: JSON & Delphi XE5

  Alt 11. Nov 2013, 07:45
Das hier sollte auch unter XE5 funktionieren:
https://bitbucket.org/Gloegg/delphi-xe-json

Bei dem eingebauten DBXJSON schreckt mich immer das viele rumgecaste ab.
Delphi-Quellcode:
procedure ParseJson;
var
  LJsonArr : TJSONArray;
  LJsonValue : TJSONValue;
  LItem : TJSONValue;
begin
   LJsonArr := TJSONObject.ParseJSONValue(TEncoding.ASCII.GetBytes(StrJson),0) as TJSONArray; // soft cast
   for LJsonValue in LJsonArr do
   begin
      for LItem in TJSONArray(LJsonValue) do // hard cast
        Writeln(Format('%s : %s',[TJSONPair(LItem).JsonString.Value, TJSONPair(LItem).JsonValue.Value])); // 2x hard cast
     Writeln;
   end;
end;
  Mit Zitat antworten Zitat