How to convert a string of values into a list of values

Hi,
I’m trying to convert this string: {1,2,3,4,5,6,7,8,9} into a list of values 1 2 3 4 5 6 7 8 9.
I have created a java service, but I am getting these brackets as well, could you please help me out?
here is what i have done, your advice is always beneficial.
Thanks in advance.


this is the java service which is getting a string and returning a list

this is the first map of my flow service

this is the 2nd map of my flow service

and this is the result i’m getting

Regards
hmafzal

Hi @hmafzal ,
Have you tried checking the built in services especially the pub.string services , https://documentation.softwareag.com/webmethods/integration_server/pie10-5/10-5_Integration_Server_Built_In_Services_Reference.pdf,
You may not need to write a java service.
You can use the pub.string:substring to remove the { symbol at the first index , followed by pub.string:tokenize passing , as an delimiter.

-NP

2 Likes

Hi @hmafzal,

This could be solved in many ways, it is on the logic that you want to get your string converted to a list of elements.

If you are sure that every time your input is going to within { } then you could trim that off in your java service, just like this input = input.substring(1, input.length()-1);

Try and let me know if it works as per your expectation.

Thanks,
Sree

Hi Sreekhanth
I’m really thankful for your reply.
it is working like a charm.
Regards
hmafzal

1 Like

Thanks Nagendra

Glad to see you used split instead of tokenize. The tokenize method has behaviors that you likely do not want.

Regarding calling demoStrToChars is there a reason to call that using a transformer? Not an issue per se, but often people use transformers thinking it has behaviors that do not exist. We have a convention where if the transformer is the only item in the MAP step, don’t use a transformer. Just invoke the service. Improves readability.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.