<cfwddx>
Serializes and de-serializes CFML data structures to the XML-based WDDX format.
Generates JavaScript statements to instantiate JavaScript objects equivalent to the contents of a WDDX packet or some CFML data structures.
This tag cannot have a body.
This tag is also supported within <cfscript>
<cfwddx
action=cfml2wddx|wddx2cfml|cfml2js|wddx2js
input=any
output=string
toplevelvariable=string
usetimezoneinfo=boolean
validate=boolean
xmlconform=boolean
>
Examples
Simple Example with tag format
<cfset qry = queryNew("id,test","integer,varchar",[{id:1,test:"test"},{id:2,test:"name"}])>
<cfdump var="#qry#" label="Query">
<cfwddx action="cfml2wddx" input="#qry#" output="WDDX_qry">
<cfdump var="#WDDX_qry#" label="action=cfml2wddx">
<cfwddx action="wddx2cfml" input="#WDDX_qry#" output="CFML_qry">
<cfdump var="#CFML_qry#" label="action=wddx2cfml">
<cfwddx action="cfml2js" topLevelVariable="CFML_js" input="#qry#" output="CFML_js">
<cfdump var="#CFML_js#" label="action=cfml2js">
<cfwddx action="wddx2js" topLevelVariable="test" input="#WDDX_qry#" output="WDDX_js">
<cfdump var="#WDDX_js#" label="action=wddx2js">
Simple Example with script format
// This WDDX packet contains a struct with 4 keys: 3 strings and 1 array of numbers
strWDDX = "<wddxPacket version='1.0'><header/><data><struct><var name='VERSION'><string>1.0.0</string></var><var name='COUNTDOWNARRAY'><array length='5'><number>5.0</number><number>4.0</number><number>3.0</number><number>2.0</number><number>1.0</number></array></var><var name='NAME'><string>Test Struct</string></var><var name='DESCRIPTION'><string>To illustrate serializing to WDDX</string></var></struct></data></wddxPacket>";
<span class="nv">wddx</span> <span class="nv">action</span><span class="o">=</span><span class="s1">'wddx2cfml'</span> <span class="nv">input</span><span class="o">=</span><span class="nv">strWDDX</span> <span class="nv">output</span><span class="o">=</span><span class="s1">'example'</span><span class="p">;</span>
<span class="nf">dump</span><span class="p">(</span><span class="nv">example</span><span class="p">);</span>
See also
- WDDX
- DeserializeJSON()
- IsWddx()
- SerializeJSON()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)