User Guide Cancel

CanSerialize

 

Description

ColdFusion will invoke this function before invoking the serialize() function. 

Returns

Boolean. If true, the serialize() function of the custom serializer will be called. If false, ColdFusion's default serializer will be used for serialization.

Function syntax

boolean function canSerialize(type)
boolean function canSerialize(type)
boolean function canSerialize(type)

History

ColdFusion 11: Added this function. For more information see REST Enhancements in ColdFusion 11.

Parameters

Parameter

Description

type

Required. String. The type to which the data has to be serialized.

Example

<cffunction access="remote" name="canSerialize" returntype="boolean">
<cfargument name="type" type="string"/>
<!--- If you need to serialize only XML using the custom serializer. --->
<cfif #type# eq "XML">
<cfreturn true>
<cfelse>
<cfreturn false>
</cfif>
</cffunction>
<cffunction access="remote" name="canSerialize" returntype="boolean"> <cfargument name="type" type="string"/> <!--- If you need to serialize only XML using the custom serializer. ---> <cfif #type# eq "XML"> <cfreturn true> <cfelse> <cfreturn false> </cfif> </cffunction>
<cffunction access="remote" name="canSerialize" returntype="boolean">

<cfargument name="type" type="string"/>

<!--- If you need to serialize only XML using the custom serializer. --->
<cfif #type# eq "XML">

<cfreturn true>

<cfelse>

<cfreturn false>

</cfif>

</cffunction>

Get help faster and easier

New user?