IDtJsonProvider.File

Syntax

File: String;

Description

The File property determines the path and the name of the JSON file, from which data is to be imported.

Example

Executing the example requires the D:\Work\Data.json JSON file.

Example of File Structure

An ETL task with the ETL identifier is created in the repository.

Add links to the Andy, Drawing, Dt, Etl, Metabase system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    EtlTask: IEtlTask;
    EtlProvider: IEtlPlainDataProvider;
    JSONProvider: IDtJsonProvider;
    WxProvider: IWxRectangle;
    WxETLProvider: IWxETLObject;
Begin
    MB := MetabaseClass.Active;
    
//Search for ETL task. Repository object wih the ETL identifier
    MObj := MB.ItemById("ETL").Edit;
    EtlTask := MObj 
As IEtlTask;
    
//Provider creation start
    //Create the Import from JSON provider
    EtlProvider := EtlTask.Create(EtlObjectType.PlainDataJsonProvider) As IEtlPlainDataProvider;
    EtlProvider := EtlProvider.Edit;
    EtlProvider.Id := 
"JSON_Provider";
    EtlProvider.Name := 
"Import from JSON";
    EtlProvider.Description := 
"Import from JSON";
    
//Set up data provider
    JSONProvider := EtlProvider.Provider As IDtJsonProvider;
    JSONProvider.File := 
"D:\Work\Data.json";
    JSONProvider.Query := 
"$..data";
    EtlProvider.FillDefault;
    
//Save provider
    EtlProvider.Save;
    
//Provider creation end
    //Visual object creation start
    WxProvider := EtlTask.Workspace.CreateRectangle;
    WxETLProvider := 
New WxETLObject.Create;
    WxETLProvider.ETLObject := EtlProvider;
    WxProvider.Style.TextPosition := WxTextPosition.Bottom;
    WxProvider.Style.PictureMarginTop := -
10;
    WxProvider.PinPosition := 
New GxPointF.Create(5050);
    WxProvider.Extension := WxETLProvider 
As IWxShapeExtension;
    
//Visual object creation end
    //Save ETL task
    MObj.Save;
End Sub UserProc;

On executing the example a new data provider will be created in ETL task - Import from Json. The data provider is set up to work with the specified file.

See also:

IDtJsonProvider