One Star

[resolved] tFileOutputJSON - How to change order of fields

Title says it mostly. To specify, my incoming rows are already arranged in their proper arrangement, but how come they are scrambled up once the JSON file was generated? (i.e. they are not in the order of the input rows).
Thanks in advance,
1 ACCEPTED SOLUTION

Accepted Solutions
Community Manager

Re: [resolved] tFileOutputJSON - How to change order of fields

Hi
I tested and got the same issue, as alternative solution, you can use tWriteJsonFiled+tFileOutputDelimited to generate a json file, tWriteJsonFiled provides a visual GUI that allows you to configure the json structure more easy. eg:
...tWriteJsonField--main--tFileOutputDelimtied
----------------------------------------------------------
Talend | Data Agility for Modern Business
7 REPLIES
Community Manager

Re: [resolved] tFileOutputJSON - How to change order of fields

Hi 
Can you please show us an example to explain your problem? What is the result you are getting and what are you expected result?
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tFileOutputJSON - How to change order of fields

Hello,
Here is a breakdown of the order:

tLogRow output to print values before creating JSON file:
+----------------+-----------+
| key            | value     |
+----------------+-----------+
| givenName      | BRIDGITTE |
| surname        | TIMPSON   |
| Sex            | Female    |
| Code           | Passport  |
| Code1          | P         |
| Code2          | <         |
| birthDate      | {30/2/99} |
| documentNumber | 308722518 |
| expirationDate | {1/1/16}  |
| format         | PASSPORT  |
| issuingCountry | GBR       |
| nationality    | GBR       |
+----------------+-----------+

JSON file structure:
{
  "MRZ Fields":
}
How come they are not in order? My Job simply has tJavaRow -- tLogRow -- tFileOutputJSON as components, with all columns being propagated to the next component.
Community Manager

Re: [resolved] tFileOutputJSON - How to change order of fields

Hi
I tested and got the same issue, as alternative solution, you can use tWriteJsonFiled+tFileOutputDelimited to generate a json file, tWriteJsonFiled provides a visual GUI that allows you to configure the json structure more easy. eg:
...tWriteJsonField--main--tFileOutputDelimtied
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tFileOutputJSON - How to change order of fields

Atleast I know its not some bug that only I was experiencing.
So does this mean my job would now look like:
tJavaRow -- tLogRow -- tWriteJsonField -- tFileOutputDelimited
Community Manager

Re: [resolved] tFileOutputJSON - How to change order of fields

Yes, let me know if you are able to generate the json file as expected. 
----------------------------------------------------------
Talend | Data Agility for Modern Business
One Star

Re: [resolved] tFileOutputJSON - How to change order of fields

Hi
I tested and got the same issue, as alternative solution, you can use tWriteJsonFiled+tFileOutputDelimited to generate a json file, tWriteJsonFiled provides a visual GUI that allows you to configure the json structure more easy. eg:
...tWriteJsonField--main--tFileOutputDelimtied

i tried this solution but the field names(column names) we have to add manually in tWriteJsonField.
I mean while entering the schema we have to add field names manually.
schemas are not auto generated nor copyable Smiley Sad
if i have a file with 100 columns. just imagine how much work i have to do. this was the situation i am facing ri8 now. please tell me any other solution.
Community Manager

Re: [resolved] tFileOutputJSON - How to change order of fields

Hi vhkhari 
To generate a Json file, we can use tFileOutputJson or tWriteJsonFields+tFileOutputDelimited, no other component can be used to write a Json file now. 
Best regards
Shong
----------------------------------------------------------
Talend | Data Agility for Modern Business