Editare

Partajați prin


JsonQueryStringConverter.ConvertValueToString(Object, Type) Method

Definition

Serializes a Common Language Runtime (CLR) parameter type to a JavaScript Object Notation (JSON) representation.

public:
 override System::String ^ ConvertValueToString(System::Object ^ parameter, Type ^ parameterType);
public override string ConvertValueToString (object parameter, Type parameterType);
override this.ConvertValueToString : obj * Type -> string
Public Overrides Function ConvertValueToString (parameter As Object, parameterType As Type) As String

Parameters

parameter
Object

The parameter value to convert.

parameterType
Type

The Type of the parameter to serialize.

Returns

The JSON query string parameter serialization of the CLR type. null is returned if the parameter is null.

Examples

Consider the following operation.

[WebGet]  
[OperationContract] public int GetOptionQuote(string ticker, DateTime dte, Option opt);  

This operation produces a URL that is a URL-encoded version of the following.

http://localhost/quote.svc/GetOptionQuote?ticker="MSFT"&dte="\/Date(50067823)\/"&opt={"type":"call","strikePrice":"35"}  

Remarks

The converter overrides ConvertValueToString(Object, Type) so that each parameter is serialized to JSON using the default DataContractJsonSerializer and a JSON XML Writer configured to use the UTF-8 encoding. Unlike its base type, this converter can handle any type adhering to the Data Contract model.

Applies to