Skip to main content Skip to complementary content
Close announcements banner

Parsing JSON and XML fields

A pipeline with a source, two Parser processors, and a destination.

Before you begin

  • You have previously added the dataset holding your source data.

    Here, a dataset with both JSON and XML fields containing user data including names and addresses:

    Download the file: unparsed-users.csv.

    Import it as a local dataset and configure the Header field to 1 in order to define the first line of the file as a header.

  • You also have created the connection and the related dataset that will hold the processed data.

    Here, a Test dataset.

Procedure

  1. Click Add pipeline on the Pipelines page. Your new pipeline opens.
  2. Give the pipeline a meaningful name.

    Example

    Parse JSON and XML user fields
  3. Click ADD SOURCE to open the panel allowing you to select your source data, here a mix of unparsed JSON and XML user data entered manually as a test dataset.
    Preview of a data sample with unparsed user records.
  4. Select your dataset and click Select in order to add it to the pipeline.
    Rename it if needed.
  5. Click Plus and add a Parser processor to the pipeline. The configuration panel opens.
  6. Give a meaningful name to the processor.

    Example

    parse JSON fields
  7. In the Configuration area:
    1. Select JSON in the Format list as you first want to parse the input JSON fields.
    2. Select .json in the Field to process list, as you want to transform the JSON fields corresponding to the user ages.
    3. Enable Enforce number as double to make sure that input numbers, such as the age, are converted into Double data type.

    Look at the preview of the processor to compare your data before and after the parsing operation.

    Preview of the Parser processor after parsing JSON records about user age.
  8. Click Plus and add another Parser processor to the pipeline. The configuration panel opens.
  9. Give a meaningful name to the processor.

    Example

    parse XML fields
  10. In the Configuration area:
    1. Select XML in the Format list as you first want to parse the input XML fields.
    2. Select .xml in the Field to process list, as you want to transform the XML fields corresponding to the user addresses.
  11. Click Save to save your configuration.

    Look at the preview of the processor to compare your data before and after the parsing operation.

    Preview of the Parser processor after parsing XML records about user addresses.
  12. Click ADD DESTINATION and select the dataset that will hold your output data.
    Rename it if needed.
  13. On the top toolbar of Talend Cloud Pipeline Designer, click the Run button to open the panel allowing you to select your run profile.
  14. Select your run profile in the list (for more information, see Run profiles), then click Run to run your pipeline.

Results

Your pipeline is being executed, the input JSON and XML fields have been parsed and transformed into JSON and XML objects.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – let us know how we can improve!