Reputation: 11
And how I can convert this to CF
$client = array( array( "apPat" => 'Estrada', "apMat" => 'Castillo' ) );
I need to send this object to net webservice from CF but the Webservice not accept it.
I tried
<cfset client = arraynew[]>
<cfset client[1] = structnew()>
<cfset client[1].apPat = "Estrada">
<cfset client[1].apMat = "Castillo">
this is my real code
<cfset arrAgente[1] = {}>
<cfset arrAgente[1].ramoTecnico = "1">
<cfset arrAgente[1].codAgente = "5095">
<cfset emissionRequest = {}>
<cfset emissionRequest.ramoTecnico = "1">
<cfset emissionRequest.codAgente = "5095">
<cfset emissionRequest.poliza = {}>
<cfset emissionRequest.poliza.codTipoPoliza = "2">
<cfset emissionRequest.poliza.ramoComercial = "5">
<!--- here is where I have problems beacuse I need to send an array or a list. The above code I dont have problems, the Net recognize it like a single array the structures----->
<cfset emissionRequest.agente = #arrAgente#>
Upvotes: 0
Views: 107
Reputation: 13548
I don't know PHP but a quick search tells me that array(array())
creates a multi-dimensional array in PHP. And in the comments you mention (I think) needing a multi-dimensional array - The Net not recognize like array of array ... If that is the case then you need to create a multi-dimensional array in ColdFusion. You do that like this (reference):
<cfset arrAgente = ArrayNew(2) />
So you might try something like this:
<cfset arrAgente = ArrayNew(2) />
<cfset strAgente = StructNew() />
<cfset strAgente.apPat = "Estrada">
<cfset strAgente.apMat = "Castillo">
<cfset arrAgente[1][1] = strAgente />
Which gives you this:
If case matters (notice that gives you ALL CAPS for the index names) then try it this way which preserves the case you give it:
<cfset arrAgente = ArrayNew(2) />
<cfset strAgente = StructNew() />
<cfset rv = StructInsert(strAgente,"apPat","Estrada") />
<cfset rv = StructInsert(strAgente,"apMat","Castillo") />
<cfset arrAgente[1][1] = strAgente />
Which gives you this:
Upvotes: 0
Reputation: 29870
client
is a scope in CFML, so I doubt you can write to it like that. Use a different variable name ("client" is not a very descriptive variable name in the first place, anyhow).
Docs: "Scope types"
Upvotes: 4