SerializeJSON does not use custom Getters

Description

If I create an component with a few numeric properties, and for one of those properties i write a custom getter, then serializeJSON does not pick up on that.

Example code:

Test.cfc

component accessors=true { property name="number1" type=numeric getter="false"; property name="number2" type=numeric; property name="sum" type=numeric; public numeric function getSum() { return variables.number1 + variables.number2; } }

index.cfm

<cfscript> run(); function run() { var oTest = new Test(); oTest.setNumber1(10); oTest.setNumber2(20); writeDump(oTest); writeDump(serializeJSON(oTest)); } </cfscript>

In lucee 5.3.8+189 this results in the json output {"number1":10,"number2":20}

In adobe 2018.0.11+326016 this results in the json output {"number2":20,"sum":30.0}

Environment

None

Activity

Zac Spitzer 
1 June 2022 at 07:40

Pothys - MitrahSoft 
26 July 2021 at 15:29

I added a testcase to this ticket

Pull Request: https://github.com/lucee/Lucee/pull/1394

Ben Ferdinandus 
26 July 2021 at 13:06

Ah yes, You are correct in getting this result {"number2":20,"sum":30.0} in AdobeCF.

Pothys - MitrahSoft 
23 July 2021 at 16:26

I've checked this ticket and confirmed the issue happened on lucee latest version 5.3.8.193-SNAPSHOT also.
There are two incompatibilities in component serialize JSON result in lucee with ACF.

    1. If we set getter is false, ACF doesn't include that property in serializeJSON results. But lucee Includes that property too.
    2. And serialize JSON of a component doesn't pick up the custom getter function and its Includes the result based on property value.

 

with ACF 2018,0,11,326016 . I got this result {"number2":20,"sum":30.0} without number1 value

Details

Assignee

Reporter

Priority

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Created 23 July 2021 at 11:09
Updated 1 June 2022 at 07:40