Using a map in a Data Integration Job
Create a Job to convert a JSON file into a CSV.
About this task
In this example, you have a JSON file containing customer information,
including arrays of different types of phone numbers. The goal is to convert it into a
simple CSV file with a column for each piece of information. You can use the following
JSON sample as
input:
{
"customers":[
{
"firstName":"John",
"lastName":"Smith",
"age":25,
"address":{
"streetAddress":"21 2nd Street",
"city":"New York",
"state":"NY",
"postalCode":"10021"
},
"phoneNumber":[
{
"type":"home",
"number":"202-555-0109"
},
{
"type":"mobile",
"number":"202-555-0181"
}
]
},
{
"firstName":"Jane",
"lastName":"Doe",
"age":31,
"address":{
"streetAddress":"19 4th Street",
"city":"New York",
"state":"NY",
"postalCode":"10021"
},
"phoneNumber":[
{
"type":"home",
"number":"202-555-0178"
},
{
"type":"mobile",
"number":"202-555-0123"
},
{
"type":"work",
"number":"202-555-0163"
}
]
}
]
}
Creating the input structure for your Data Integration Job
Create a JSON structure based on a sample document to use as input for your mapping.
Before you begin
About this task
Creating structures in the Hierarchical Mapper is especially useful when handling files with multiple nested levels. You can create them directly from the Metadata node in your Repository in the Integration perspective, or from the Data Mapper tab in the Mapping perspective.
For more information, see Working with structures.
Procedure
- Expand the Hierarchical Mapper node and right-click Structure, then click .
- In the wizard that opens, select Import a structure definition and click Next.
- Select JSON Sample Document and click Next.
-
Select the file to use:
- Select an existing resource in your workspace.
- Import a local file.
- Enter the URL to the file.
- Click Next.
- Select a folder and enter a name for your structure, then click Next.
- Click Finish.
Results
Creating the Data Integration Job
Create a simple Job with a tFileInputRaw, a tHMap and a tFileOutputDelimited.
Procedure
Results
Mapping the elements for your Data Integration Job
Configure the map generated in the previous procedure.
Procedure
Results
You can use the Test Run option to test the output, and go
back to your Job to run it. The output should look like this with the sample input
data:
John,Smith,25,21 2nd Street,New York,NY,10021,202-555-0109,202-555-0181,
Jane,Doe,31,19 4th Street,New York,NY,10021,202-555-0178,202-555-0123,202-555-0163