Status/Resolution/Reason: Closed/Fixed/Fixed
Reporter/Name(from Bugbase): James Partin / ()
Created: 04/17/2018
Components: Language, Serialization
Versions: 2016
Failure Type: Data Corruption
Found In Build/Fixed In Build: 2016,0,04,302561 / ColdFusion 2018
Priority/Frequency: Normal / All users will encounter
Locale/System: ALL / Windows 7 64-bit
Vote Count: 0
Problem Description:
SerializeJSON loses type info from properties defined in the parent class when serializing a subclass.
Steps to Reproduce:
foo.cfc:
{code:java}
/**
* @output false
* @accessors true
**/
component{
/**
* @getter true
* @setter false
**/
property string numStr;
variables.numStr = "";
/**
* @output false
**/
public foo function init(){
variables.numStr = "1234";
return this;
}
}
{code}
bar.cfc:
{code:java}
/**
* @output false
* @accessors true
* @extends foo
**/
component{
/**
* @output false
**/
public bar function init(){
variables.numStr = "1234";
return this;
}
}
{code}
test.cfm:
{code:java}
<cfscript>
cFoo = new foo();
Writeoutput(SerializeJSON(cFoo)); //{"numStr":"1234"}
cBar = new bar(); //inherits from foo.cfc
Writeoutput(SerializeJSON(cBar)); //{"numStr":1234} //do you even datatype bro??
</cfscript>
{code}
Actual Result:
{"numStr":1234}
Expected Result:
{"numStr":"1234"}
Any Workarounds:
None. Tried setting metadata on variables scope in the cfc, but naturally, variables scope is not a true struct.
Attachments:
Comments: