json Integer/Float to String

When I parse a json message some of the fields are Integer/Long, Double/Float which is fine. However, is there a built in service that converts these values to a String?

I can create my own java service, but wanted to check first.

Thanks,
Joe

Hi Joseph,

you can check for the Package WmTransformationServices, which should be available in the Download section of the community.

Regards,
Holger

wM Version?

You may try and use pub.math:toNumber if this applies.

Oops… this does not work…Ignore the previous message.

I have searched the site, but I am unable to locate where I can download the WmTransformationServices package from. Any help would be appreciated.

Thanks,
Joe

Unfortunately WmTransformationServices package is not available on the SAG tech community.

The package “WmTransformationServices” is not supported by SAG (just like PSUtils) as it is not a part of the official webMethods product stack. However, this package is widely used by on-site/off-site consultants and they implement & provide this package as a custom service.

However you can use the below code snippet and create your own java service, the same code is implemented in WmTransformationServices.

//IntegerToString
public static final void IntegerToString(IData idata)
throws ServiceException
{
IDataCursor idatacursor = idata.getCursor();
Integer integer = (Integer)IDataUtil.get(idatacursor, “input”);
idatacursor.destroy();
String s = null;
if(integer != null)
s = integer.toString();
idatacursor = idata.getCursor();
IDataUtil.put(idatacursor, “output”, s);
idatacursor.destroy();
}

//FloatToString

public static final void FloatToString(IData idata)
throws ServiceException
{
IDataCursor idatacursor = idata.getCursor();
Float float1 = (Float)IDataUtil.get(idatacursor, “input”);
idatacursor.destroy();
String s = null;
if(float1 != null)
s = float1.toString();
idatacursor = idata.getCursor();
IDataUtil.put(idatacursor, “output”, s);
idatacursor.destroy();
}

Thanks, Mahesh.

Try pub.string:objectToString in WmPublic, it converts any Object to String.

I second that. I would also suggest to go with wmpublic built in service pub.string: objectToString instead of writing a custom service.

Using the objectToString flow worked. Thanks for all the feedback.

-Joe