Configuring the tExtractJSONFields components for looping - 8.0

Extracting data from a JSON file through looping

Version
8.0
Language
English
Module
Talend Studio
Content
Last publication date
2024-02-20

Procedure

  1. In the schema editor of the first tExtractJSONFileds component, add the following columns in the output table.
    • Guid, type String;
    • TransactionId, type Integer;
    • Products, type Object
  2. Close the schema editor and click Yes in the subsequent dialog box to propagate the schema to the next component.
    The columns just added appear in the Mapping table of the Basic settings view.
  3. Set the other options in the Basic settings view as follows.
    • JSON field: Transactions;
    • Loop Jsonpath query: "*" (in double quotation marks);
    • Guid: empty, for receiving the Guid value from the previous component;
    • TransactionId: "TransactionId" (in double quotation marks);
    • Products: "Products" (in double quotation marks);
    • Others: unchanged
    The settings loop all the elements within the Transactions element and extract the values of the TransactionId and the Products elements.
  4. In the schema editor of the second tExtractJSONFileds component, add the following columns in the output table.
    • Guid, type String;
    • TransactionId, type Integer;
    • ProductId, type String;
    • Packs, type Object
  5. Close the schema editor and click Yes in the subsequent dialog box to propagate the schema to the next component.
    The columns just added appear in the Mapping table of the Basic settings view.
  6. Set the other options in the Basic settings view as follows.
    • JSON field: Products;
    • Loop Jsonpath query: "*" (in double quotation marks);
    • Guid: empty, for receiving the Guid value from the previous component;
    • TransactionId: empty, for receiving the TransactionId from the previous component;
    • ProductId: "ProductId" (in double quotation marks);
    • Packs: "Packs" (in double quotation marks);
    • Others: unchanged
    The settings in the above figure loop all the elements within the Products element and extract the values of the ProductId and the Packs elements.
  7. In the schema editor of the third tExtractJSONFileds component, add the following columns in the output table.
    • Guid, type String;
    • TransactionId, type Integer;
    • ProductId, type String;
    • Quantity, type Integer;
    • Price, type Float;
    • Due_Date, type Date
  8. Close the schema editor and click Yes in the subsequent dialog box to propagate the schema to the next component.
    The columns just added appear in the Mapping table of the Basic settings view.
  9. Set the other options in the Basic settings view as follows.
    • JSON field: Packs;
    • Loop Jsonpath query: "*" (in double quotation marks);
    • Guid: empty, for receiving the Guid value from the previous component;
    • TransactionId: empty, for receiving the TransactionId value from the previous component;
    • ProductId: empty, for receiving the ProductId value from the previous component;
    • Quantity: "Quantity" (in double quotation marks);
    • Price: "Price" (in double quotation marks);
    • Due_Date: "Due_Date" (in double quotation marks);
    • Others: unchanged
    The settings in the above figure loop all the elements within the Packs element and extract the values of the Quantity, the Price, and the Due_Date elements.