Let’s say I have a component with 2 properties
<cfcomponent name="Thing">
<cfproperty name="property1" type="numeric" />
<cfproperty name="property2" type="numeric" />
</cfcomponent>
I want to be able to serialize this component using serializeJSON()
How would I ensure that property1 is included in the JSON and not property 2 ?
I tried what I thought must be it by setting serializable=“false” on property 2, but that does not seem to apply when serializing the object as JSON.
My next approach was to create my own function on the object named “toJSON()” that filtered the properties by their serializable setting and only serialized those where it was true. This works great for shallow properties, but sometimes I have properties that are another object and I need to ensure the properties on that object are also not serialized. Before I get into creating a recursive function to solve this problem, I wonder if this is even the best way?
For reference, .NET has a [JsonIgnore] attribute
that can be used to achieve this. I basically want the same behaviour.