JSON array structure to get the information

Highlighted
Six Stars

JSON array structure to get the information

Hi everybody,

 

I would like your opinion about this problem :

 

- I have these contents from a first job ( tOutputDelimited ):

 

[{ ...
"labels": "[{\"idBoard\":\"57f269e64ebba4d3bfbc3fee\",\"color\":\"pink\",\"name\":\"Webapp\",\"uses\":53,\"id\":\"57f2721584e677fd36aa3646\"}]"
}]

 

- from a second job, I get these contents (tInputDelimited) :

...
},
		"labels": "\"label_name\": \"Webapp\","
	}

I would like to recover all the information of "labels" of the first job under JSON array and specially delete  the "\" in order to have like a JSON array :

 

["labels" : "blabla" ]

What do you suggest to me to do this thing : TMap ( to clean the file ) or TJava to set the structure of the file ? Tell me...

 

Thanks

 

 


Accepted Solutions
Six Stars

Re: JSON array structure to get the information

Hi everybody,

 

Finally I solved the problem :

 

- I used a tJavaRow and i added a code to get the label name, that is :

 

//get the label name under JSON array model
output_row.json = output_row.json.replaceAll("(\"\\w+\")\\s*:[^:]+:\\s*\\\\\\\"(\\w+)\\\\\\\",\"","$1: \\[\"$2\"\\]");

As a result I get :

"labels": ["Webapp"],

https://regex101.com/r/UVqVYo/1

 


All Replies
Six Stars

Re: JSON array structure to get the information

Finally, I am working with "tJavaRow" componant.

Moderator

Re: JSON array structure to get the information

Hi,

Thanks for your feedback and sharing your solution with us. Could you please set this topic as resolved?

Best regards

Sabrina

--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
Six Stars

Re: JSON array structure to get the information

Hi everybody,

 

Finally I solved the problem :

 

- I used a tJavaRow and i added a code to get the label name, that is :

 

//get the label name under JSON array model
output_row.json = output_row.json.replaceAll("(\"\\w+\")\\s*:[^:]+:\\s*\\\\\\\"(\\w+)\\\\\\\",\"","$1: \\[\"$2\"\\]");

As a result I get :

"labels": ["Webapp"],

https://regex101.com/r/UVqVYo/1

 

What’s New for Talend Spring ’19

Watch the recorded webinar!

Watch Now

Definitive Guide to Data Quality

Create systems and workflow to manage clean data ingestion and data transformation.

Download

Tutorial

Introduction to Talend Open Studio for Data Integration.

Watch

Downloads and Trials

Test drive Talend's enterprise products.

Downloads