How can I prevent SerializeJSON from changing Yes/No/True/False strings to boolean?
Posted
by Dan Roberts
on Stack Overflow
See other posts from Stack Overflow
or by Dan Roberts
Published on 2009-12-08T15:33:41Z
Indexed on
2010/03/17
6:51 UTC
Read the original article
Hit count: 312
coldfusion
|JSON
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
© Stack Overflow or respective owner