CFJSON 1.8 is out
Saturday, May 12th, 2007

It’s been a while I’ve updated CFJSON, I just finished looking over some suggestions I’d received by email and took a little time to implement and test them. One fix could be considered critical depending on your needs. Ray Camden pointed out that Yahoo’s JSON feeds escaped the forward-slash character, so a url was coming up as http:\/\/someURL.com . This was not being decoded correctly by CFJSON, which I fixed for this release. For consistency, I also modified the encode function to escape the forward-slash.

The next two changes are some optional features that might make your life easier. The first was a suggestion by Carl Anderson for the handling of numeric fields. He was having problems because he had some project codes like “5.10000″ which javascript would convert to 5.1. He recommended that numbers be converted to strings by default in JSON. Because So he added a stringNumbers argument to the encode() function, when set to true it will encode numbers as strings. Because I don’t like to tamper with data unless necessary, I preferred to set the default to false.

Next up was the handling of dates. Thomas Jaworski pointed out that dates in an ODBC format like {ts ’2007-04-15 16:03:25′} would be troublesome to parse, so he provided some code for the encode() function to format dates in a way that was friendly to javascript’s new Date() constructor. Again, because I don’t like to tamper with data I preferred to implement this as an option that is false by default. The encode() function takes an optional formatDates boolean argument which will format dates as follows: May 12, 2007 3:00:45 PM .

Hopefully these features will come in handy. As always, your feedback is welcome, keep the requests/suggestions coming!

Leave a Reply