Read jSON with multiple data

Highlighted
Five Stars

Read jSON with multiple data

Hi there,

 

I´m in trouble in reading data from a jSON-File with the following input:

 

{
"accountid": "AEX6376734",
"exhibitortype": "New Exhibitor",
"street": "Teststreet 1234",
"city": "Test City",
"email": "test@test.com"
"contact": {
"firstname": "Frank",
"lastname": "Master",
"contactphone": "+49 342823873",
"contactfax": null,
"contactmobile": null,
"contactemail": null,
"gender": null,
"salutation": null
}
}
{
"accountid": "AEX734875448",
"exhibitortype": "New Exhibitor",
"street": "Teststreet 5678",
"city": "Test City2",
"email": "test123231@test.com"
"contact": {
"firstname": "Robert",
"lastname": "Master",
"contactphone": "+49 12345",
"contactfax": null,
"contactmobile": null,
"contactemail": null,
"gender": null,
"salutation": null
}
}

 

I tried to create a meta-schema for this jSON but I only get the first data of this jSON. So it seems that it don´t iterate over the rest of the file.

So my result must return two sets of data.

 

AccountID: AEX6376734

AccountID: AEX734875448

 

My solution should be:

 

tFileInputJson -> tIterateToFlow -> tLogRow to test if it works.

 

Is anyone able to show me a solution how to read all the data iterated into tLogRow? How should I define loop element if I don´t have a group element.

 

Thx for your help.

 

 

Highlighted
Nine Stars

Re: Read jSON with multiple data

How about something like this - tFileInputJSON - main - tMap - main - tLogRow

 

Job Layout - 

tFileInputJSON-3.JPGtFileInputJSON-4.JPGtMap-TC3.JPGAlso, your json seems to be wrong and doesn't get validated. It should be something like this - 

		[{
			"accountid": "AEX6376734",
			"exhibitortype": "New Exhibitor",
			"street": "Teststreet 1234",
			"city": "Test City",
			"email": "test@test.com",
			"contact": {
				"firstname": "Frank",
				"lastname": "Master",
				"contactphone": "+49 342823873",
				"contactfax": null,
				"contactmobile": null,
				"contactemail": null,
				"gender": null,
				"salutation": null
			}
		}, {
			"accountid": "AEX734875448",
			"exhibitortype": "New Exhibitor",
			"street": "Teststreet 5678",
			"city": "Test City2",
			"email": "test123231@test.com",
			"contact": {
				"firstname": "Robert",
				"lastname": "Master",
				"contactphone": "+49 12345",
				"contactfax": null,
				"contactmobile": null,
				"contactemail": null,
				"gender": null,
				"salutation": null
			}
		}]
Highlighted
Nine Stars

Re: Read jSON with multiple data

How about something in the line of tFileInputJSON - > main - > tMAP -> main -> tLogRow

tFileInputJSON-3.JPGtFileInputJSON-4.JPGtMap-TC3.JPG

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog