# CFWDDX

The CFWDDX tag serializes and de-serializes CFML data structures to the XML-based WDDX format. You can also use it to generate JavaScript statements instantiating JavaScript objects equivalent to the contents of a WDDX packet or some CFML data structures.

### Syntax

    <CFWDDX ACTION="action"
        INPUT="inputdata"
        OUTPUT="resultvariablename"
        TOPLEVELVARIABLE="toplevelvariablenameforjavascript"
        USETIMEZONEINFO="Yes/No">

#### ACTION

Specifies the action taken by the CFWDDX tag. Use one of the following:

- CFML2WDDX -- Serialize CFML to WDDX format
- WDDX2CFML -- Deserialize WDDX to CFML
- CFML2JS -- Serialize CFML to JavaScript format
- WDDX2JS -- Deserialize WDDX to JavaScript

#### INPUT

Required. The value to be processed.

#### OUTPUT

The name of the variable to hold the output of the operation. This attribute is required for ACTION=WDDX2CFML. For all other actions, if this attribute is not provided, the result of the WDDX processing is outputted in the HTML stream.

#### TOPLEVELVARIABLE

Required when ACTION=WDDX2JS or ACTION=CFML2JS. The name of the top-level JavaScript object created by the deserialization process. The object created by this process is an instance of the WddxRecordset object, explained in WddxRecordset Object .

This attribute applies only when the ACTION is WDDX2JS or CFML2JS.

#### USETIMEZONEINFO

Optional. Indicates whether to output time-zone information when serializing CFML to WDDX. If time-zone information is taken into account, the hour-minute offset, as represented in the ISO8601 format, is calculated in the date-time output. If time-zone information is not taken into account, the local time is output. The default is Yes.

### Usage

Use this tag to serialize and deserialize packets of data used to communicate with the browser.

For complete information on WDDX, see the "Programming with XML " chapter in Developing Web Applications with ColdFusion.

### Example

    <!--- This snippet shows basic use of the CFWDDX tag. --->
    <HTML>
    <HEAD>
        <TITLE>CFWDDX Tag</TITLE>
    </HEAD>
    <BODY>
    <!--- Create a simple query  --->
    <CFQUERY NAME='q' DATASOURCE='cfsnippets'>
        select Message_Id, Thread_id, Username from messages
    </CFQUERY>

    The recordset data is:...<P>
    <CFOUTPUT QUERY=q>
        #Message_ID# #Thread_ID# #Username#<br>
    </CFOUTPUT><P>

    <!--- Serialize data to WDDX format --->
    Serializing CFML data...<P>
    <CFWDDX ACTION='cfml2wddx' input=#q# output='wddxText'>

    <!--- Display WDDX XML packet --->
    Resulting WDDX packet is:
    <xmp><CFOUTPUT>#wddxText#</CFOUTPUT></xmp>

    <!--- Deserialize to a variable named wddxResult --->
    Deserializing WDDX packet...<P>
    <CFWDDX ACTION='wddx2cfml' input=#wddxText# output='qnew'>

    The recordset data is:...<P>
    <CFOUTPUT QUERY=qnew>
        #Message_ID# #Thread_ID# #Username#<br>
    </CFOUTPUT><P>
    </BODY>
    </HTML>