Managed Hosting



Project Home Blog Known Issues Contact Project

JSONUtil Issue: data.charAt needs cast to int

Name: data.charAt needs cast to int
ID: 14
Project: JSONUtil
Type: Bug
Area: Code
Severity: Normal
Status: Open
Related URL: https://gist.github.com/machristie/14e85ba1ab798bcd3cfa/revisions
Creator: Marcus Christie
Created: 12/04/14 1:07 PM
Updated: 12/04/14 1:07 PM
Description: I'm working with version 1.5 of JSONUtil.cfc

My CF server is on version 7.02, I believe. In writeJsonUtf8String I get an error about the method charAt not being available.

Eventually I was able to fix it by casting the "i" variable to an "int".

Here's a patch:

diff --git a/JSONUtil.cfc b/JSONUtil.cfc
index 96db556..620fe87 100644
--- a/JSONUtil.cfc
+++ b/JSONUtil.cfc
@@ -578,7 +578,7 @@ limitations under the License.
      <cfset var hex = "" />
      <cfloop from="0" to="#end#" index="i">
-         <cfset c = data.charAt(i) />
+         <cfset c = data.charAt(JavaCast("int", i)) />
         <cfif c lt ' '>
<cfif c eq Chr(8)>
<cfset json = json & "\b" />
@@ -609,4 +609,4 @@ limitations under the License.
\ No newline at end of file

(The added newline at the end isn't necessary, of course).

I also included this change in a Gist: https://gist.github.com/machristie/14e85ba1ab798bcd3cfa/revisions
History: Created by machristie (Marcus Christie) : 12/04/14 1:07 PM

To add a comment to this bug, please login using the link above.