Configuring the components - 6.5

JSON

author
Talend Documentation Team
EnrichVersion
6.5
EnrichProdName
Talend Big Data
Talend Big Data Platform
Talend Data Fabric
Talend Data Integration
Talend Data Management Platform
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for Big Data
Talend Open Studio for Data Integration
Talend Open Studio for ESB
Talend Open Studio for MDM
Talend Real-Time Big Data Platform
task
Data Governance > Third-party systems > File components (Integration) > JSON components
Data Quality and Preparation > Third-party systems > File components (Integration) > JSON components
Design and Development > Third-party systems > File components (Integration) > JSON components
EnrichPlatform
Talend Studio

Procedure

  1. Double-click the tFileInputJSON component to open its Basic settings view.
  2. Select JsonPath without loop from the Read By drop-down list. Then select the Use Url check box and in the URL field displayed enter the URL of the file facebook.json from which the data will be retrieved. In this example, it is http://localhost:8080/docs/facebook.json.
  3. Click the [...] button next to Edit schema and in the [Schema] dialog box define the schema by adding one column friends of String type.
    Click OK to close the dialog box and accept the propogation prompted by the pop-up dialog box.
  4. In the Mapping table, enter the JSONPath query "$.user.friends[*]" next to the friends column to retrieve the entire friends node from the source file.
  5. Double-click tExtractJSONFields to open its Basic settings view.
  6. Select Xpath from the Read By drop-down list.
  7. In the Loop XPath query field, enter the XPath expression between double quotation marks to specify the node on which the loop is based. In this example, it is "/likes/data".
  8. Click the [...] button next to Edit schema and in the [Schema] dialog box define the schema by adding five columns of String type, id, name, like_id, like_name, and like_category, which will hold the data of relevant nodes under the JSON field friends.
    Click OK to close the dialog box and accept the propogation prompted by the pop-up dialog box.
  9. In the XPath query fields of the Mapping table, type in the XPath query expressions between double quotation marks to specify the JSON nodes that hold the desired data. In this example:
    • "../../id" (querying the "/friends/id" node) for the column id,

    • "../../name" (querying the "/friends/name" node) for the column name,

    • "id" for the column like_id,

    • "name" for the column like_name, and

    • "category" for the column like_category.

  10. Double-click the second tLogRow component to open its Basic settings view.
    In the Mode area, select Table (print values in cells of a table) for better readability of the result.