I'm working on an XML serializer. It describes data types so I'm looking for a nice way to determine datatype in CFML.
The idea is to pass in an arbitrary object (any value - a string, a query, a number, a struct, etc). The serializer will recurse down the object generating the XML. To do this it will attempt to determine the datatype of each value it encounters. It's easy enough to use the various "Is" functions but they're flakey at best for this. Simple CF datatypes aren't clearly discoverable. For example: +) Is "1" a boolean? How about "True"? +) Is "1e3435654" a number or a string (CF says "number")? +) Is something that looks like a date a date or a string? In JavaScript I settled this by only trusting "real" typed objects... Dates had to have the Date constructor, Booleans had to Boolean constructor and so forth... but that's not possible in CFML. I know that, arbitrarily, I can't KNOW, for sure, whether "1" is a Boolean or a number (or a string for that matter)... but I'd at least like to offer some way for a developer to force the type into the assignment if possible. For example <cfset foo = true /> is clearly Boolean while "<cfset foo = "true" /> isn't... but I can't figure out a way to determine which was used after the fact. I'd also settle for a mostly right decision ladder to pick the most likely simple type... I can then make simple type discovery an option in the parser - but I'd rather not if I don't have to. Anybody have any insight to how the built-in WDDX parse does this same task? Thanks, Jim Davis ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Find out how CFTicket can increase your company's customer support efficiency by 100% http://www.houseoffusion.com/banners/view.cfm?bannerid=49 Message: http://www.houseoffusion.com/lists.cfm/link=i:4:219194 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

