Share this page

# web_convert_to_formatted

Formats data using one or more data format extensions.

## C Language

    int web_convert_to_formatted ("RawData=<data_string>", "TargetParam=<parameter_name>", "ChainName=<name>", LAST );

Data Format Functions

## Java Language

    int object.convert_to_formatted( const char *RawData, const char *TargetParam, String [] {"ChainName=<name>", "LAST"} );

Data Format Functions | Java Syntax

Argument | Description
--- | ---
RawData | The data to format. Additional information about the data can be provided with web_convert_from_formatted.
TargetParam | The name of a parameter. The formatted string will be saved in this parameter.
ChainName | The data format chain name is the value of the ChainName parameter from the chain INI file. The chain can be a chain you create or one of the supplied chains.
LAST | A marker indicating the end of the argument list.

## Return Values

This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.

## Parameterization

You cannot use standard parameterization for any arguments in this function.

## General Information

The web_convert_to_formatted function formats data using one or more data format extensions.

This function can be used if Data Format Extensions are enabled in the Runtime Settings.

## Raw Data Qualifiers

The raw data can be qualified. Only one qualifier can be used. For text, no qualifier is used. The qualifiers are:

RawData/EscapedBinary - The raw data is a null-terminated string containing binary codes represented with escaped characters. The data is converted to binary before being passed to the data format chain. See Binary Code.

RawData/BinaryParam - The raw data is the name of a parameter containing binary data.

## Example - C

This example shows a call to web_convert_to_formatted with the data format extension specified in the Extensions argument.

To use this sample code:

- Create chains named myChainName1, myChainName2, and myChainName3 using the Data Format Extension user interface.
- Define a parameter named myBinaryDataBuffer. The parameter stores binary data.

Copy code

    web_convert_to_formatted (
        "RawData= {\"firstName\": \"John\",\"lastName\": \"Smith\"}",
        "TargetParam=DFE_Param1",
        "ChainName=myChainName1",
        LAST );

    web_convert_to_formatted (
        "RawData/EscapedBinary=\\xAC\\xED\\x00\\x05sr\\x005"
            "org.springframework.remoting.support.RemoteInvocation_l"
            "\\x8B\\x9F\\xF6\n\\x11\n"
            "\\x02\\x00\\x04[\\x00\targumentst"
            "\\x00\\x13[Ljava/lang/Object;L\\x00\n"
            "attributest\\x00\\x0FLjava/util/Map;L\\x00\n"
            "methodNamet\\x00\\x12Ljava/lang/String;"
            "[\\x00\\x0EparameterTypest\\x00\\x12"
            "[Ljava/lang/Class;xpppt\\x00\\x0BisAvailableur"
            "\\x00\\x12[Ljava.lang.Class;"
            "\\xAB\\x16\\xD7\\xAE\\xCB\\xCDZ\\x99"
            \\x02\\x00\\x00xp\\x00\\x00\\x00\\x00",
        "TargetParam=DFE_Param2",
        "ChainName=myChainName2",
        LAST );

    web_convert_to_formatted (
        "RawData/BinaryParam= myBinaryDataBuffer",
        "TargetParam=DFE_Param3",
        "ChainName=MyChainName3",
        LAST );

## Example - Java

convert_from_formatted

This example shows a call to lrapi.web.convert_from_formatted with the data format extension provided with the wrapping XML of the formatted data.

Copy code

    lrapi.web.convert_from_formatted("FormattedData=" +
        "<LR_EXTENSION name=\"Base64\">test string</LR_EXTENSION>",
        "TargetParam=DFE_BODY", new String[]{
        "LAST"});

Copy code

    lrapi.web.convert_from_formatted("FormattedData=test string",
        "TargetParam=DFE_BODY", new String[]{"Extensions=Base64", "LAST"});

Copy code

    lrapi.web.convert_to_formatted("RawData=dGVzdCBzdHJpbmc=",
        "TargetParam=DFE_Param1",
        new String[]{"ChainName=c1", "LAST"});

Tips to improve your search results... VuGen Function Reference Version 26.1-26.3 Function Reference 26.1-26.3 All View Local Help Center View Online Help Center Version: