Wait, are you converting a query to a structure of arrays just so you can then 
convert that to JSON?

If so, stop it - it's unnecessary.

If you're on CF8 you can add cffunction attributes returnformat="JSON" and 
queryformat="row|column" as appropriate and just cfreturn the query.

If you're on CF7 you can use cfjson which is a CFC that will 
serialise/deserialise for you http://cfjson.riaforge.org/



And while I'm here, that query should have a cfqueryparam in it.

<cfquery name="getDis" datasource="foo">
  SELECT * FROM users
  where emplid in (<cfqueryparam list="true" value"#emplids#" 
cfsqltype="cf_sql_integer"/>)
  ORDER BY empname
</cfquery>


And, *if* you really do need to create your own array of structures, you can 
drop that initial query and just do this:

<cfloop query="getDis">
  <cfset LOCAL[getDis.CurrentRow] = StructNew()>

  <cfloop list=#getDis.ColumnList# index="ColName">
    <cfset LOCAL[getDis.CurrentRow][ColName] = 
getDis[ColName][getDis.CurrentRow] >
  </cfloop>

</cfloop>

Not the CurrentRow and ColumnList properties of the query, saves you creating 
other variable that do the same job. 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to 
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f

Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:318502
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4

Reply via email to