Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
PRIYABOSCH
Contributor
Contributor

Extra "\" in JSON file produced | urgent issue

Dear Experts,

I am very new to talend. I need to generate a json file. 0683p000009M5fG.pngthe job flow is created like below. I have two issues

 

 

 

1. I need to generate the json with headers.

{  
"title": "data Identifier % Quality Data",  
"description": "JSON Schema for data IDs
{
---
---
}
}

I am not sure how this can be achieved with twritejsonfield and tfileoutputjson components.

2. I am getting extra "\" in the output json file created from tfileoutputjson component. Please let me know how this can be eliminated.

 

Thank you!

Best Regards,

Priya

Labels (4)
12 Replies
Anonymous
Not applicable


@subhadip13 wrote:

Hi @Psiphon Download

 

Your JSON generated is absolutely correct.

 

The problem is in the file you are validating as JSON, every line i.e. each start of the item JSONTESTFLAT is a JSON structure and your validating tool is expecting the whole file to be a JSON, that means it is expecting after line 1 there should be a , and then line 2 and then 3, 4 etc.

 

TWriteJSONFileds will generate as many JSONs as many groups are there in the input data, which is perfectly fine in this case.

 

To validate the structure you can just put one line and check if the JSON generated is valid or not using your Validating tool.

 

Thanks and Regards,

Subhadip


The problem is after generating JSON using tWriteJSONFields when you again use tFileOutputJSON the escape character appears.

 

Write the each row line by line to tFileOutputDelimited, you will get similar JSON but without escape character.

PRIYABOSCH
Contributor
Contributor
Author

Hi Subhadip,

 

You are exactly correct. The JSON file is validating correctly with ROW by ROW. But I want to send this whole data to KAKFA and REST.

I have two questions:

1. Is there any other way to avoid extra "\" from the output of Twritejsonfield? or the data will be passed to Rest and KAFKA without "\" if I connect from TWRITEJSONFIELD component to the rest or kafka.

 

2. I believe if we parse the json data with the below code in tjavarow after twritejsonfield this "\" will be eliminated.

 

import org.json.simple.JSONObject;

import org.json.simple.parser.JSONParser;

JSONParser jsonParser = new JSONParser();

JSONObject obj = (JSONObject) jsonParser.parse(row3.JSONTEST);

row4.JSONTEST = obj.toString();

 

0683p000009M5ty.png

 

 

is my understanding is correct. but here I am getting null pointer exception.

 

Please let me know your feedback.

 

Thank you!

Regards,

Priya

 

Anonymous
Not applicable

Hi @PRIYABOSCH ,

 

If you want to send the whole data as a single JSON object, you have to chose the group element which is unique in the input file.

 

Thanks and Regards,

Subhadip