It is a new function of 10.2.2, and it can be outputted by Ext JS store definition.

Posted by on in Programming

New in 10.2.2 TFDBatchMoveJSONWriter was added.

TFDBatchMoveJSONWriter is a Writer that combines with TFDBatchMove to out to a simple JSON. But,  TFDBatchMoveJSONWriter has the function of generating Model definition of Ext JS.
I tried with a field dynamically created with TFDMemTable.


The code below is a simple 64-bit console application.
I wrote this code using C++Builder.

#include <vcl.h>
#include <windows.h>

#pragma hdrstop
#pragma argsused
#pragma link "dbrtl.a"
#pragma link "FireDAC.a"
#pragma link "FireDACCommonDriver.a"
#pragma link "FireDACCommon.a"

#include <tchar.h>
#include <iostream>
#include <System.JSON.hpp>
#include <FireDAC.Stan.Intf.hpp>
#include <FireDAC.Stan.Option.hpp>
#include <FireDAC.Stan.Param.hpp>
#include <FireDAC.Stan.Error.hpp>
#include <FireDAC.DatS.hpp>
#include <FireDAC.Phys.Intf.hpp>
#include <FireDAC.DApt.Intf.hpp>
#include <FireDAC.Comp.BatchMove.JSON.hpp>
#include <FireDAC.Comp.BatchMove.hpp>
#include <FireDAC.Comp.BatchMove.DataSet.hpp>
#include <Data.DB.hpp>
#include <FireDAC.Comp.DataSet.hpp>
#include <FireDAC.Comp.Client.hpp>
#include <FireDAC.Stan.StorageJSON.hpp>
#include <functional>
#include <string>
#include <sstream>

struct dbs
    TFDMemTable* f_MemTable1;
    TFDBatchMove* f_BatchMove1;
    TFDBatchMoveDataSetReader* f_DataSetReader1;
    TFDBatchMoveJSONWriter* f_JSONWriter1;
    TFDStanStorageJSONLink* f_JSONLink1;
    dbs(std::function<void(TFDMemTable*)> func)
        f_MemTable1         = new TFDMemTable(nullptr);
        f_BatchMove1        = new TFDBatchMove(nullptr);
        f_DataSetReader1    = new TFDBatchMoveDataSetReader(nullptr);
        f_JSONWriter1       = new TFDBatchMoveJSONWriter(nullptr);
        f_JSONLink1         = new TFDStanStorageJSONLink(nullptr);
        f_DataSetReader1->DataSet   = f_MemTable1;
        f_BatchMove1->Reader        = *f_DataSetReader1;
        f_BatchMove1->Writer        = *f_JSONWriter1;
    static inline String IToString(int iin)
        std::wostringstream ss;
        ss << iin;
        return ss.str().c_str();

        delete f_MemTable1;
        delete f_BatchMove1;
        delete f_DataSetReader1;
        delete f_JSONWriter1;
        delete f_JSONLink1;

int _tmain(int argc, _TCHAR* argv[])
        TStringList* alist = new TStringList();
            dbs adbs([](TFDMemTable* memt)
                    //Field definition of TFDMemTable* instance.
                    //Create five fields.
                    for (int i = 0; i < 5; i++)
                        TStringField* aField    = new TStringField(nullptr);
                        aField->FieldName       = "Column" + dbs::IToString(i);
                        aField->Size            = 50;
            //Then execute the GenerateExtJSModel() method.
            //This GenerateExtJSModel() is a TFDBatchMoveJSONWriter class that has been added than 10.2.2.
            adbs.f_JSONWriter1->GenerateExtJSModel("Table1", true, alist);
            //Console out.
            std::wcout << alist->Text.c_str() << std::endl;
            delete alist;


    return 0;

result GenerateExtJSModel()

The output store definition is as follows.

Ext.define('Table1', {
  extend: '',
  requires: [
  fields: [
    { name: 'Column0', type: 'string' },
    { name: 'Column1', type: 'string' },
    { name: 'Column2', type: 'string' },
    { name: 'Column3', type: 'string' },
    { name: 'Column4', type: 'string' }

It can be output in Ext JS store definition.

Gold User, No rank,
Delphi / C++Builder blogger


  • Alexander T25496
    Alexander T25496 Thursday, 17 May 2018

    There is a bug in Delphi 10.2.3 code in this function.
    Local variable "iLevel" is uninitialized. And calling this function produces unpredictable results.

  • haruyuki mohri
    haruyuki mohri Thursday, 17 May 2018

    Thanks for the report.
    Have you registered this in the URL below?

  • Please login first in order for you to submit comments
  • Page :
  • 1

Check out more tips and tricks in this development video: