Share this page

# web.convertToFormatted

Data Format Functions

Formats data using one or more data format extensions.

Note: This function can be used if Data Format extensions are enabled in the runtime settings. See the Virtual User Generator Help Center.

## Syntax

    web.convertToFormatted ( {object} );

## JavaScript Object

    {
       rawData:"<string>" | rawData: {value: "<string>",
       flag: "<EscapedBinary | BinaryParam>"},
       targetParam:"<string>",
       chainName:"<string>"
    }

Property Name | Description
--- | ---
rawData | The data to format. Additional information about the data can be provided with web.convertFromFormatted.
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.

## Return Values

Not applicable

## Parameterization

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

## General Information

The web.convertToFormatted 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. See the Virtual User Generator Help Center.

## Example

    	lr.saveString('\x63\x57\x46\x31\x63\x32\x56\x79\x4F\x6E\x46\x68\x64\x58\x4E\x6C\x63\x67\x3D\x3D',
    			'encodedParam');

    	web.convertToFormatted(
    		{
    		rawData: 'cWF1c2VyOnFhdXNlcg==',
    		targetParam: 'decoded',
    		chainName: 'Base64test'
    		}
    	);

    	lr.message('decoded value = ['+lr.evalString('{decoded}')+']');

    	web.convertToFormatted(
    		{
    		rawData: {value: '\x63\x57\x46\x31\x63\x32\x56\x79\x4F\x6E\x46\x68\x64\x58\x4E\x6C\x63\x67\x3D\x3D',
                     flag: 'EscapedBinary'},
    		targetParam: 'decoded_plus',
    		chainName: 'Base64test'
    		}
    	);

    	lr.message('decoded value = ['+lr.evalString('{decoded_plus}')+']');

    	web.convertToFormatted(
    		{
    		rawData: {value: 'encodedParam', flag: 'binaryParam'},
    		targetParam: 'decoded_a',
    		chainName: 'Base64test'
    		}
    	);

    	lr.message('decoded value = ['+lr.evalString('{decoded_a}')+']');

    	web.regSaveParamEx(
    		{
    			paramName : 'body',
    			lb : '',
    			rb : '',
    			scope : 'Body'
    		}
    	);
    	web.url(
    		{
    			name : 'clear.gif',
    			url : 'http://kalimanjaro/sources/Caching/Mens_files/clear.gif',
    			resource : 1,
    		}
    	);

    	web.saveParamLength("body", "Decimal");
    	lr.message('Body size is: ['+lr.evalString('{body_Length}')+'] bytes');

    	web.convertFromFormatted (
    		{
    		formattedData: {value: 'body', flag: 'binaryParam'},
    		targetParam: 'encoded_body',
    		extensions: 'Base64'
    		}
    	);

    	web.convertToFormatted(
    		{
    		rawData: {value: 'encoded_body', flag: 'binaryParam'},
    		targetParam: 'decoded_body',
    		chainName: 'Base64test'
    		}
    	);

    	web.saveParamLength("decoded_body", "Decimal");
    	lr.message('Body size is: ['+lr.evalString('{decoded_body_Length}')+'] bytes');

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: