Coldfusion 10 - Element [n] is undefined in a Java object of type class coldfusion.runtime.Array -


i upgraded system cf8 cf10 , have 1 bug i'm having problems tracking down. has remote api call gets json string , string gets converted query object. that's i'm coming across error:

element [n] undefined in java object of type class coldfusion.runtime.array. problem in function converts string query.

<cffunction name="cfjsontoquery" access="public" returntype="query" output="no">   <cfargument name="cfdata" required="yes" type="struct"/>   <cfset var local = {}/>     <cfset local.tmpqry = querynew( arraytolist(arguments.cfdata.data.columns) ) />        <cfloop index = "i" = "1" = "#arraylen(arguments.cfdata.data.data)#">          <cfset local.row = queryaddrow(local.tmpqry) />            <cfloop index="k" from="1" to="#arraylen(arguments.cfdata.data.data[i])#">              <cfset local.colname = arguments.cfdata.data.columns[k]/>              <cfset querysetcell(local.tmpqry,local.colname,arguments.cfdata.data.data[i][k],local.row)/>            </cfloop>            </cfloop>   <cfreturn local.tmpqry/> </cffunction>     

anywhere json returns 'null' (i.e. "...","19107-3609",null,null,null,"...") error thrown. i've tried using isnull check if it's null in cfloop:

<cfif isnull(arguments.cfdata.data.data[i][k])>    <cfset arguments.cfdata.data.data[i][k] = 'i null'/> </cfif> 

edit - here's simplified example - issue way newer deserializejson() works believe:

<cfset jstr = '{"success":true,"errors":[],"data":{"columns":["id","fname","lname"],"data":[[390132,"steve",null]]}}'/> <cfset cfdata = deserializejson(jstr) />   <cfloop index = "i" = "1" = "#arraylen(cfdata.data.data)#">     <cfset row = queryaddrow(tmpqry) />       <cfloop index="k" from="1" to="#arraylen(cfdata.data.data[i])#">         <cfset colname = cfdata.data.columns[k]/>         <cfset querysetcell(tmpqry,colname,cfdata.data.data[i][k],row)/>       </cfloop>   </cfloop> 

i've tried sorts of tests empty string, isnull etc. , i'm still not sure how query object built if deserializejson returns:

[undefined array element] element 3 undefined in java object of type class coldfusion.runtime.array. 

this seem work:

<cfset cfdata = deserializejson(returndata,'false') /> <cfset qrydata = cfdata.data /> 

this lets me use qrydata if normal cfquery.

you can check if element undefined using cf function arrayisdefined(array, elementindex)


Comments

Popular posts from this blog

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

javascript - How to name a jQuery function to make a browser's back button work? -