I think I found a bug in serializeJSON(). We have ...
# cfml-general
a
I think I found a bug in serializeJSON(). We have an MSSQL db table with BIT columns, when I populate a coldfusion object with a property type of numeric or boolean, then create a memento structure from the properties of the object, then run serializeJSON on that structure, the first record will convert the columns that were of BIT in the db (but numeric or boolean in the object) to a string. All records after the first in the array convert the BIT columns to a non-quoted number. If I do a CAST AS INT on the BIT columns, then they all serialize properly as numbers. Is there something different about a struct key with a value from a BIT column? Its got me all confused.
b
@aaronstoddard Can you provide a trycf.com example that demonstrates this?
a
I can't really because the data seems to be dependant on the database column type. If I define a struct in code, it seems to serialize normally. Something about the conversion from BIT to INT or BOOLEAN datatypes seems to cause the issue. I'll see what I can whip up, if a copy/paste will be sufficient
If no one else has ever encountered this, then I'll chalk it up to something I have going on locally
b
You should be able to use querynew() to create the same query data
a
I'll give that a shot
Oh, and this is ACF2021
b
I'm not sure if one encountered it because without seeing code I didn't really understand what you're saying, lol
a
I can't replicate the behavior in TryCF. I was able to serialized it just fine there...it has to be something I'm doing because I've never had just one record out of a whole collection just refuse to serialize correctly. I'll keep debugging. I thought if it was a known thing maybe someone had a quick fix, but its likely I just borked it on my own. Thanks Brad. See you at CFSummit next month!
r
Can you use a custom serializer in the serializeJSON call?