UNIT Unit1;

INTERFACE

USES
  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, System.StrUtils,
  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, REST.Types, System.Rtti, FMX.Grid.Style,
  FireDAC.Stan.Intf, FireDAC.Stan.Option, FireDAC.Stan.Param, FireDAC.Stan.Error, FireDAC.DatS,
  FireDAC.Phys.Intf, FireDAC.DApt.Intf, Data.Bind.EngExt, FMX.Bind.DBEngExt, FMX.Bind.Grid, System.Bindings.Outputs,
  FMX.Bind.Editors, Data.Bind.Components, Data.Bind.Grid, Data.Bind.DBScope, Data.DB,
  FireDAC.Comp.DataSet, FireDAC.Comp.Client, REST.Response.Adapter, FMX.ScrollBox, FMX.Grid, FMX.Controls.Presentation,
  FMX.StdCtrls, REST.Client, Data.Bind.ObjectScope, FMX.Edit, FMX.Memo.Types, FMX.Memo;

TYPE
  TForm1 = CLASS(TForm)
    RESTClient1: TRESTClient;
    RESTRequest1: TRESTRequest;
    RESTResponse1: TRESTResponse;
    Button1: TButton;
    RESTResponseDataSetAdapter1: TRESTResponseDataSetAdapter;
    FDMemTable1: TFDMemTable;
    BindSourceDB12: TBindSourceDB;
    BindingsList1: TBindingsList;
    Edit1: TEdit;
    Edit2: TEdit;
    LinkControlToField4: TLinkControlToField;
    LinkControlToField2: TLinkControlToField;
    Memo1: TMemo;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    PROCEDURE Button1Click(Sender: TObject);
    Procedure GetData(texto: STRING);
  PRIVATE
    { Private declarations }
  PUBLIC
    { Public declarations }
  END;

VAR
  Form1: TForm1;

IMPLEMENTATION

{$R *.fmx}

PROCEDURE TForm1.Button1Click(Sender: TObject);
BEGIN
  RESTRequest1.Execute;

  GetData(Edit1.Text);
  GetData(Edit2.Text);

END;

Procedure TForm1.GetData(texto: STRING);
VAR
  i: integer;
  aux: STRING;
  datos: TStringDynArray;
BEGIN
  aux := texto;
  FOR i := LOW(texto) TO HIGH(texto) DO
  BEGIN
    IF (ansipos(aux[i], '{}[]"')) > 0 THEN
      aux[i] := ' ';
  END;
  aux := stringreplace(aux, ' ', '', [rfreplaceAll]);
  datos := SplitString(aux, ',');
  FOR i := 0 TO length(datos) - 1 DO
  BEGIN
    datos[i] := stringreplace(datos[i], ':', '=', [rfreplaceAll]);
    Memo1.lines.add(datos[i]);
  END;
END;

END.
