Put your initial array inside a scope.
VARIABLES['response'] = {};
Then you'd refere to it like so:
VARIABLES['response']['hotspots'] = [];
On a side note, it's irritating that it does this, but you can code for it
on the client as long as you know it's happening. ColdFusion itself could
care less if the variables are uppercase, lowercase, or some mixture.
andy
-----Original Message-----
From: Glyn Jackson [mailto:[email protected]]
Sent: Thursday, July 01, 2010 5:11 AM
To: cf-talk
Subject: issues preserving the case of the key
Hi
Having more issues with a JSON request. the page calling the service is case
sensitive, this was solved using the bracket structure syntax: i.e.
response['hotspots'] = []; to preserve the case of the key. however I have
an array I have tried added the array different ways to the struct but it
still comes out uppercase!
<cfscript>
var response = StructNew();
var tempArray=ArrayNew(1);
var obj = "";
response['hotspots'] = [];
obj =
{
distance = "100",
attribution="This is a test layer POI provider",
title= "My layer - snowy4",
lon= "53.472696",
lat="-2.261843",
imageURL="null",
line4="RADIOLIST-None,CustSlider-None",
line3="SEARCHBOX - asdfdgxdg",
line2="DevlId - 896Settings: range=1000'",
actions="",
type="0",
id="test_1"
};
arrayappend(response['hotspots'],obj);
response['layer'] = "testme";
response['errorString']='ok';
response['morePages']='false';
response['errorCode']= '0';
response['nextPageKey']='null';
</cfscript>
also tried
<cfscript>
var response = StructNew();
response['hotspots'] = [
{
distance ="100",
attribution="This is a test layer POI provider",
title= "My layer - snowy4",
lon= "53.472696",
lat="-2.261843",
imageURL="null",
line4="RADIOLIST-None,CustSlider-None",
line3="SEARCHBOX - asdfdgxdg",
line2="DevlId - 896Settings: range=1000'",
actions="",
type="0",
id="test_1"
}];
arrayappend(response, hotspots);
response['layer'] = "testme";
response['errorString']='ok';
response['morePages']='false';
response['errorCode']= '0';
response['nextPageKey']='null';
</cfscript>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology-Michael-Dinowitz/dp/1430272155/?tag=houseoffusion
Archive:
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:335009
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm