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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Ray0801
Creator
Creator

How to read a json file with unwanted / before every "?

Can someone help

Labels (3)
1 Solution

Accepted Solutions
gjeremy1617088143

So you can read Data as key first : it will extract :

{\"Id\":\"101\",\"Name\":\"AAA\"}

then you use in a tJavaRow or tMap : StringUtils.replaceAll((your string), "\\\\\"","\"") on the extract

and after you can use an other textractjsonfield on the result

Loop Jsonpath query : "$"

 

Mapping :

Column Json query

Id "Id"

Name "Name"

View solution in original post

5 Replies
gjeremy1617088143

Hi could you be more precise , wich one do you want to remove?

Send me Love and Kudos

Ray0801
Creator
Creator
Author

@guenneguez jeremy​  My json file has a / before each " ,I am not able to parse the values properly due to this.Is it possible to read the file with this extra \.

 

Data example:

[{Data:"{\"Id\":\"101\",\"Name\":\"AAA\"}"}]

 

If I read the file as it is in talend my output is

Data as key and the whole part as values {\"Id\":\"101\",\"Name\":\"AAA\"}

 

While I want to read ID as key and 101 as value,to me the only possible option seems to be removing the \ ,but that is causing json format issue.

 

Is it possible to read the data properly without removing the \.

 

gjeremy1617088143

Hi , you have to replace \" by " so :

you can read your json as a string with a tFileInputRaw, it will create an object type,

you convert it to a String with a tConvertType,

in a tJavaRow or tMap : StringUtils.replaceAll((your string), "\\\\\"","\"")

then you can write it on a tfileoutputRaw.

Finally you can read the new file and extract json,

 

 

input :

[{Data:"{\"Id\":\"101\",\"Name\":\"AAA\"}"}]

output :

[{Data:"{"Id":"101","Name":"AAA"}"}]

 

but your json is not valid

it should be :

[{"Data":{"Id":"101","Name":"AAA"}}]

 

Send me LOve and Kudos

gjeremy1617088143

So you can read Data as key first : it will extract :

{\"Id\":\"101\",\"Name\":\"AAA\"}

then you use in a tJavaRow or tMap : StringUtils.replaceAll((your string), "\\\\\"","\"") on the extract

and after you can use an other textractjsonfield on the result

Loop Jsonpath query : "$"

 

Mapping :

Column Json query

Id "Id"

Name "Name"

Ray0801
Creator
Creator
Author

@guenneguez jeremy​ Thanks!