tmpVal = "'" + value.replace(/'/, "''") + "'";
tmpVal = "'" + value.toString().replace(/'/, "''") + "'";
It would be great if you could cast variables on the ColdFusion side using JavaCast(). As it stands now SerializeJSON does not respected the Java type of a variable as the following code demonstrates:
<cfset valToSerialize = JavaCast("String",123) />
<cfset class = valToSerialize.getClass() />
<cfset json = SerializeJSON(valToSerialize) />
This may not be possible as all simple values, numeric, string, or boolean, are stored as Strings in CF, so you generally want some type of implicit conversion to take place. Maybe SerializeJSON could have a strict parameter which forced it to honor the Java type of the variable?
Well, enough thinking out loud. This is just something else to look out for when using JSON with CF.