JSON Parse

Hi George

I prefer more Delphi style something like this:

type
  TMyDataValue = record
    ID: Integer;
    DESCRIPTION: string;
  end;

  TMyJsonDataArray = record
    TableName: string;
    Values: Array of TMyDataValue;
  end;

  TMyJsonData = record
    ERRORS: string;
    WARNINGS: string;
    MESSAGES: string;
    DATA: Array of TMyJsonDataArray;
  end;

procedure TForm1.ParseMyJSON2;
var
  txt: string;
  JS: JSValue;
  MyJsonData: TMyJsonData;
  I,J: Integer;
begin
  WebMemo2.Lines.Clear;
  asm
    debugger;
  end;
  txt := WebMemo1.Lines.Text;
  asm
    JS = JSON.parse(txt);
  end;
  MyJsonData := TMyJsonData(JS);
  if isDefined(MyJsonData.ERRORS) then
    WebMemo2.Lines.Add('Has "ERRORS" with value "'+ MyJsonData.ERRORS + '"');

  if isDefined(MyJsonData.WARNINGS) then
    WebMemo2.Lines.Add('Has "WARNINGS" with value "'+ MyJsonData.WARNINGS + '"');

  if isDefined(MyJsonData.MESSAGES) then
    WebMemo2.Lines.Add('Has "MESSAGES" with value "'+ MyJsonData.MESSAGES + '"');

  if isDefined(MyJsonData.DATA) then
  begin
    for I := 0 to Length(MyJsonData.DATA) -1 do
    begin
      if isDefined(MyJsonData.DATA[I].TableName) then
        WebMemo2.Lines.Add('Has "TableName" with value "'+MyJsonData.DATA[I].TableName+'"');
      for J := 0 to Length(MyJsonData.DATA[I].Values) -1 do
      begin
        WebMemo2.Lines.Add(MyJsonData.DATA[I].Values[J].ID.ToString + ': ' + MyJsonData.DATA[I].Values[J].DESCRIPTION);
      end;
    end;
  end;
end;