webMethods

webMethods

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

json Integer/Float to String

  • 1.  json Integer/Float to String

    Posted Thu July 28, 2016 02:54 PM

    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


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 2.  RE: json Integer/Float to String

    Posted Thu July 28, 2016 03:41 PM

    Hi Joseph,

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

    Regards,
    Holger


    #webMethods
    #Integration-Server-and-ESB
    #Flow-and-Java-services


  • 3.  RE: json Integer/Float to String

    Posted Thu July 28, 2016 03:48 PM

    wM Version?

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


    #Flow-and-Java-services
    #Integration-Server-and-ESB
    #webMethods


  • 4.  RE: json Integer/Float to String

    Posted Thu July 28, 2016 03:50 PM

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


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 5.  RE: json Integer/Float to String

    Posted Thu July 28, 2016 06:12 PM

    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


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 6.  RE: json Integer/Float to String

    Posted Fri July 29, 2016 08:04 AM

    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();
    }


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB


  • 7.  RE: json Integer/Float to String

    Posted Fri July 29, 2016 02:27 PM


  • 8.  RE: json Integer/Float to String

    Posted Thu September 08, 2016 03:50 AM

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


    #Integration-Server-and-ESB
    #Flow-and-Java-services
    #webMethods


  • 9.  RE: json Integer/Float to String

    Posted Mon September 19, 2016 03:00 PM

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


    #Flow-and-Java-services
    #webMethods
    #Integration-Server-and-ESB


  • 10.  RE: json Integer/Float to String

    Posted Mon September 19, 2016 06:43 PM

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

    -Joe


    #webMethods
    #Flow-and-Java-services
    #Integration-Server-and-ESB