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

 

 

  • Data Quality
1 ACCEPTED SOLUTION

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

 

3 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

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