Skip to main content
Announcements
SYSTEM MAINTENANCE: Thurs., Sept. 19, 1 AM ET, Platform will be unavailable for approx. 60 minutes.
cancel
Showing results for 
Search instead for 
Did you mean: 
karandama2006
Creator
Creator

Extract data separated by Equal to (=)

Hello ,

While generating token from RESTAPI , I get below response

serverURL    = "https://tableau-sandbox.com"

credentialsToken = "AWHBsYtEQ2OiIJV2tqdasdasOGH2aSD44zbgaHWztlVLe7plIFES4"

siteId      = "07aqwe5422e135-4b6b2234-099be525871c"

siteContentUrl  = "Talend"

userId      = "32aa851d-fb20-49b3-8eed-7f83c406f85a"

userName     = "TALEND_TALEND"

This is not XML/JSON , looks like non-standard format, how can we extract token information using talend job ?

Labels (4)
1 Solution

Accepted Solutions
karandama2006
Creator
Creator
Author

Okay , so I tried to convert it to JSON file, but there were more obstacles than just simply replacing = with :

I did proceed with making it JSON , not very efficient , but I used below code in tjavarow and then extracted the fields using tjsonextract

 

context.response = input_row.ResponseContent;

context.response = context.response.replaceAll("=",":");

context.response = context.response.replaceAll("# REST API session created by Tableau Assist","");

context.response = context.response.replaceAll("serverURL","\"serverURL\"");

context.response = context.response.replaceAll("credentialsToken","\"credentialsToken\"");

context.response = context.response.replaceAll("siteId","\"siteId\"");

context.response = context.response.replaceAll("siteContentUrl","\"siteContentUrl\"");

context.response = context.response.replaceAll("userId","\"userId\"");

context.response = context.response.replaceAll("userName","\"userName\"");

 

context.response = context.response.replaceAll("\"\n","\",");

 

context.response = "{ " + context.response + " }";

 

 

View solution in original post

4 Replies
manodwhb
Champion II
Champion II

@karan dama​ , if you have : instead of = then replace = with : by reading all json file.

 

Thanks,

Manohar

jilanisyed
Creator
Creator

Hi ,

 

Try with tExtractDelimited component

 

Thanks

Jilani Syed

vikramk
Creator II
Creator II

I think you could store the required information in global variable using java components, then you can pass it to next component.

Please let me know if it helps

karandama2006
Creator
Creator
Author

Okay , so I tried to convert it to JSON file, but there were more obstacles than just simply replacing = with :

I did proceed with making it JSON , not very efficient , but I used below code in tjavarow and then extracted the fields using tjsonextract

 

context.response = input_row.ResponseContent;

context.response = context.response.replaceAll("=",":");

context.response = context.response.replaceAll("# REST API session created by Tableau Assist","");

context.response = context.response.replaceAll("serverURL","\"serverURL\"");

context.response = context.response.replaceAll("credentialsToken","\"credentialsToken\"");

context.response = context.response.replaceAll("siteId","\"siteId\"");

context.response = context.response.replaceAll("siteContentUrl","\"siteContentUrl\"");

context.response = context.response.replaceAll("userId","\"userId\"");

context.response = context.response.replaceAll("userName","\"userName\"");

 

context.response = context.response.replaceAll("\"\n","\",");

 

context.response = "{ " + context.response + " }";