does/has anyone used a json deserializer other tha...
# cfml-general
w
does/has anyone used a json deserializer other than the BIF? i'm tired of cf turning boolean values into YES / NO
b
On Adobe?
w
yes, cf10 in this case
b
Oh, lol
That's your problem 🙂
w
sky is blue
w
any advantages to dropping to a java lib to do it
b
Adobe hasn't done that for a while
w
i can always clean up the final string myself, but i'm old and tired
b
Well, I was going to suggest the JSON Pretty Print lib, but I have no idea if it even runs on CF10
You could try a java lib, but I don't know if they will handle CFML structs/arrays natively or not
w
the snippet above runs true,false on trycf for cf10
returns, that is
b
Are you on
10.0.16
like try cf?
w

https://m.media-amazon.com/images/I/514Ijpo5NFL._AC_.jpgâ–¾

not sure, would have to check
10.0.23 fwiw. also, specifically it's the deserializer that's dumbing down the boolean into the yes/no format. would love to meet the genius that decided yes/no is the same as true/false all those years ago
b
Well, I'm sure they never foresaw JSON 😆
w
wddx was great when it was the only thing
w
yes, not limited to cf10 it appears
b
not quite
That's just a UI trick
It's really a boolean behind the scenes
Adobe CF will simply always turn a bool into a string as yes or no
w
i feel less stupid now, but still
b
But as of 2016 I think, it actually preserves the actual type underneath
you can see above, the array still re-converts to proper true/false in the JSON
w
i believe forcibly quoting booleans will 'preserve' them, but then you're just relying on implicit type conversion/evaluation
b
But in CF11 and before, ALL simple values are a
java.lang.String
behidn the scenes
Oops, I guess they didn't fix this until 2018, not 2016 like I mistakenly said above
w
will read it, despite not needing any more reminders that i'm on acf10
m
Just ask the hackers who get in your system to ETL that back to true/false WORK SMART NOT HARD 😉
f
there was a json cfc out there back in the days before they added the BIF, I’m sure you could find it on github somewhere (though it probably predates github, I’m sure someone put it on there at some point)
w
i recall that cfc. i should probably just learn to accept yes and no as boolean statements and be happy about it
do you swear to tell the YES, the whole YES, and nothing but the YES?
f
ben has one… https://github.com/bennadel/JsonSerializer.cfc that was not the one I was thinking of, but it’s probably better
w
will check it out thanks.
f
yeah this looks promising for ya:
asBoolean( key ) - Attempts to force the value to be a true boolean.