tracker issue : CF-4200656

select a category, or use search below
(searches all categories and all time range)
Title:

Objects with property defaults defined do not serialize properly

| View in Tracker

Status/Resolution/Reason: Closed/Fixed/Fixed

Reporter/Name(from Bugbase): Daniel Roberts / Daniel Roberts ()

Created: 01/12/2018

Components: Functions

Versions: 2016,2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: CF2016 Update 5 / 314612

Priority/Frequency: Normal / Some users will encounter

Locale/System: / Win 2012 Server x64

Vote Count: 0

Problem Description:

We have a web service that our clients hit either through SOAP or basic HTTP with XML or JSON response formats. We have built many response components that define the properties of the object. In previous versions of CF the object would be converted to JSON with all public values successfully. In CF2016 however the values of the object end up being just each property's default value.

Steps to Reproduce:
1. create component with property and default value
2. instantiate object and set value for the property
3. run object through serializeJSON and output result

testobject.cfc

<cfcomponent output="false">
	<cfproperty name="test" default="">
</cfcomponent>

test.cfm

<cfset obj = createObject("component", "testobject") />
<cfset obj.test = 'something' />
<cfoutput>#serializeJSON(obj)#</cfoutput>

Actual Result:

{"TEST":""}

Expected Result:

{"TEST":"something"}

Any Workarounds:

Only way around this appears to be removing the default definitions for each property.

Attachments:

Comments: