How can I prevent SerializeJSON from changing Yes/No/True/False strings to boolean?
- by Dan Roberts
I have a data struct being stored in JSON format, converted using the serializeJSON function. The problem I am running into is that strings that can be boolean in CF such as Yes,No,True,and False are converted into JSON as boolean values. Below is example code. Any ideas on how to prevent this?
Code:
<cfset test = {str='Yes'}>
<cfset json = serializeJSON(test)>
<cfset fromJSON = deserializeJSON(json)>
<cfoutput>
#test.str#<br>
#json#<br>
#fromJSON.str#
</cfoutput>
Result:
Yes
{"STR":true}
YES