web.convertToFormatted

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 (select the relevant version).

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 chains supplied with LoadRunner Professional.

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 (select the relevant version).

Raw Data Qualifiers

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

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 Using binary code.

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

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');