serialize( currentValue, propertyName )

Parameters

currentValue{*}:

The current value of the attribute.

propertyName{String}:

The name of the property being serialized.

Returns

{*|undefined}:

If undefined is returned, the value is not serialized.

Use

serialize is useful for serializing an instance into
a more JSON-friendly form. This can be used for many reasons, including saving a
can-connected instance on the server or serializing [can-route.map can-route.map]'s internal
map for display in the hash or pushstate URL.

The serialize property allows an opportunity to define how
each property will behave when the instance is serialized. This can be useful for:

Returning undefined for any property means this property will not be part of the serialized
object. For example, if the property numPages is not greater than zero, the following example
won't include it in the serialized object.