How to access a JSON structure key that starts with a number

I've got an odd issue here.  I'm accessing someone else's JSON structure so I am not able to change it.  The JSON structure keys are named with both characters and numbers like this:
0
198456
product_id
198456
1
Rashaan Houston feat Tony Loreto
artist
Rashaan Houston feat Tony Loreto
So, in other words, there's a key named "0" and a key named "product_id", both of which contain the same key.  Why they did that, I don't know, but they did.
In one of the instances, the data stored under the text-named key isn't the same as the numerical-named key.  I tried to output the data in the numerical key like this (it's an array of structures):
#strStompyJSON.data[1].0#
but I get the following error:
Invalid CFML construct found on line 41 at column 31.
ColdFusion was looking at the following text:
.0
When I do the following, it works fine:
#strStompyJSON.data[1].product_id#
So it looks as though CF doesn't like accessing a variable that starts with a number.  I am able to loop through the structure using a collection loop, and it outputs all of the keys (including the numerical ones) and their values using the following code:
<cfloop collection="#strStompyJSON.data[1]#" item="key">
#key#: #strStompyJSON.data[1][key]#<br />
</cfloop>
However, that doesn't allow me a way to access specific keys named with a number.  Is there a way that I can specifically access a key that is named with a number?
thanks!
Mike

No problem--glad it worked out.
As a follow-up to this, I'd encourage you to keep the bracket notation in mind during future development.  It is EXTREMELY useful in a lot of situations.
For example, if you're building a structure on the fly with dynamic keys, bracket notation is extremely helpful:
     <cfset authors = structnew()>
     <cfloop list="authorlist" index="name">
          <cfset authors[name] = getbooklist(name)>
     </cfloop>
Also, bracket notation is really nice when creating json from ColdFusion structures.  Consider this:
     <cfset author = structnew()>
     <cfset author.name = "Neil Gaiman">
     <cfset author.genre = "Fantasy">
     <cfset author.awesome = true>
     <cfset authorjson = serializejson(author)>
By default, the serialized json produced will have all UPPER CASE keys.  Not a big deal in most cases, but if you're returning the json to something (like a JS library) that is expecting keys in a certain case, it can be a problem.  Fortunately, bracket notation allows you to specify exactly what case you want the structure's keys to be in:
     <cfset author = structnew()>
     <cfset author['name'] = "Neil Gaiman">
     <cfset author['Genre'] = "Fantasy">
     <cfset author['AWESOME'] = true>
     <cfset authorjson = serializejson(author)>

Similar Messages

  • My Tags that started with a number are gone! I've tagged links with the tag: "3D". they are not in my tags!

    I have tagged quite a few links with "3D" : examples of pages that used 3D in their webdesign, interesting 3D software,3D tutorials... They are all gone!
    I have found, for example, the tag "+eclectic" . So extra characters ARE used in tagging.But nothing that has been tagged with a number is in my bookmarks :-(
    Maybe Mozilla should warn users not to tag using a number?
    Thanks a lot for any help!

    As best as I can tell, 20ms is around the "sweet spot". I've tried it at 10ms and almost immediately started getting faults. At 20ms it's a bit intermittent- sometimes it'll run fine for several minutes and then get a fault, sometimes not. I've tried running at 30ms as well but it's hard to prove a fault would *never* happen.
    Part of my problem is that I don't understand what all needs to happen during this timeframe. Is this an internal loop that's running too slowly, or is my Axis interface code running too slow? Would having too many front panel controls/indicators slow down FPGA access? Should I be using some type of buffer to send configuration data, and keep front panel controls to a minimum?
    I understand that front panel controls can use up memory in an FPGA, but I've got enough space, so I assumed that would be OK, but I'm certainly not sure about any of this as it's all quite new to me.
    I did go ahead and start a service request, but I noticed it was possibly a 2-day turnaround. I'm hoping someone can give me a hand on the forums as that's both quicker and more easily accessible for future users with similar problems.
    Edit: I just did a run at 30 ms, and got the fault about 6 minutes into the run. I've got the RT VI running with the front panel on my computer, along with the Distributed System Manager, and am working on other things while it runs. Not sure how repeatable this will be but take it as it is.

  • PSE8 Organizer doesn't show folders that start with a number

    when i try to "Get Photos and Videos from Files and Folders", folders that begins numerically does show up?

    Hi ..
    thanks for the your efforts about my problem. 
    after reading  your message about how "20Myfolder" works for you, i did a bit more  experimenting. it seems like my initial assumption was wrong. it is  actual any folders with a period in its name that cause it not to show  up. eg. i name my folders "01.Photos" 
    thanks

  • How do I get rid of bad email that starts with info @ they jam if opened

    Anybody know how to get rid of bad email that starts with info @ in the address bar? They jam the mail program if opened, now I have 25 that need to go! Help?

    You only need to post once. You have to have some patience. I posted this response in your other question as well.
    Don't open those emails, swipe across them in the preview window to bring up the red delete button and use that.
    If the mail app is frozen and you can't do anything in it, close it from the recents tray and reboot the iPad.
    From your home screen, double tap the home button and the recents tray will appear with all of your recent apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner of the mail app icon. Tap the home button or anywhere above the task bar.
    Reboot the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up.

  • Advice on how to access photos on an iPad that were synced from a now failed laptop? The question stems from a need to return my current iPad having just taken delivery of a new unit. Thanks

    I am after some advice on how to access photos on an iPad that were synced from a now failed laptop? The question stems from a need to return my current iPad having just taken delivery of a new unit. Thanks

    If you have a dropbox account, there's a free app (probably more) that syncs photos to your dropbox account - picbox. 
    There's also PhotoSync that syncs photos to/from a number of different services and devices.

  • I purchased pro twice but cannot figure out how to access it.  I don't have a serial number.

    i purchased pro twice but cannot figure out how to access it.  I don't have a serial number.

    Hi lisalhawkins,
    I checked with your account and it shows that you have purchased an annual subscription of Adobe ExportPDF online service. Right?
    ExportPDF service does not require a serial number to access it.
    All you need to do is sign in at "https://cloud.acrobat.com/exportpdf" using your Adobe ID and password.
    Then, you can upload PDF files from your computer and convert them to other formats like Word, PowerPoint, etc.
    On completion, you can download the converted file on your computer and edit it for further use.
    Hope I am clear. Please let me know if you have further query on the same.
    Regards,
    Anubha

  • Our benefit administrator keeps getting an error on adding a social security number that starts with a 9, that is a valid SSN for a spouse, How do we allow this to go through?

    Our benefit administrator keeps getting an error on adding a social security number that starts with a 9, that is a valid SSN for a spouse, How do we allow this to go through?

    To attempt a new chat session...
    For the link below click the Still Need Help? option in the blue area at the bottom and choose the chat option...
    http://helpx.adobe.com/x-productkb/global/service1.html

  • HT3546 I can't figure out how to install bonjour from the CD that came with my airport express.  Can anyone help?

    I can't figure out how to install bonjour from the CD that came with my airport.  Can anyone help?

    If you are having difficulties installing Bonjour from the Installation CD, you can download the latest version of Bonjour from here.

  • HT3910 Original OSX 10.5.6 and app dvd's (that came w/MBP) lost,and have recv'd replacement dvd from Apple. Once hard drive is erased and new OS w/dvd instl'd, how do I insure all applications bundle - that came with MBP - will reinstall?

    Original OSX 10.5.6 and app dvd's (that came w/MBP) lost,and have recv'd replacement dvd from Apple. Once hard drive is erased and new OS w/dvd instl'd, how do I insure all applications bundle - that came with MBP - will reinstall?

    Your profile says you have 10.6, so why bother with the original 10.5 OS?
    But to your question, before you erase anything, make a backup of your data for safe keeping and restoration. Having an external hard drive for this purpose is most useful.

  • How can I have a browser image that scrolls with images on top of it scrolling in tandem -

    How can I have a browser image that scrolls with images on top of it scrolling in tandem - so the background is a hexagon pattern with small images inside some hexagons and I want them all to be scrollable as a user uses the browser scroll bars. At the moment the background image jumps when I preview so the small hexagons all become out of alignment. Any tips appreciated. I have browser image set to tile - pinned at the middle and set to scrolling - the small images are not pinned -

    Thanks for your answer - The images on the top layer are also links and change to show they're links on rollover - so I wanted to keep them as separate graphics - and it works to a point but when I preview the page in a browser the tiled browser image always moves no matter how I pin it and then everything becomes unaligned. Any further suggestions appreciated.

  • How do i remove the 17 errors that come with the pricing userexit manual at

    how do i remove the 17 errors that come with the pricing userexit manual attached code...

    Try connecting the phone to the computer in "data storage" or "data transfer" mode, then open the memory card folder in Windows Explorer, and search the sounds there. If you can't see them, go to "Tools>Folder Options>View>Files and Folders>Hidden files and folders" and select "Show hidden files and folders". But I think that it would be a lot easyer just to remove them from the playlist manualy.
    Crossing bridges far ahead of the crowd.

  • I have an older G5 tower Power PC and the OS 10.5.8, but the firefox and safari browers are no longer supporting this computer. How can I download an older version that works with this computer?

    I have an older G5 tower Power PC and the OS 10.5.8, but the firefox and safari browers are no longer supporting this computer. How can I download an older version that works with this computer?
    Or what is the newest OS system I can load onto this computer?
    I think it is from 2006

    Hello,
    10.5.8 is the highest OSX it can run.
    TenFourFox is the most up to date browser for our PPCs, they even have G4 & G5 optimized versions...
    http://www.floodgap.com/software/tenfourfox/
    I'd avoid vesrion 24 though, as it no longer supports plug-ins like Flash.
    SeaMonkey seems pretty fast also, with many options...
    http://www.seamonkey-project.org/
    http://www.seamonkey-project.org/releases/
    Might also look into iCab & OmniWeb versions.

  • How to i replace the firefox toolbar....and remove the toolbar that starts with MOST VISITED and SUGGESTED SITES

    Somehow lost the toolbar that has the page return arrows and refresh and stop icons. How can I replace those and remove a toolbar that starts with MOST VISITED and lists several SUGGESTED SITES.

    hello kittyheckel, please see [[Navigation buttons like back, home, bookmarks and reload are missing]]. you'll want to disable the bookmarks toolbar & enable the navigation toolbar.

  • HT1349 how do i print the bonus booklets that come with some albums i have purchased

    how do i print the bonus books that come with some albums i purchased?

    I have a Mac so I tried this. I opened the booklet outside of iTunes and the app that opened it, has a print option.
    These digital booklets are simply PDF files and Adobe makes an app that can open them and print them and it is free to use.

  • How may I change the email address that goes with ...

    Hi, 
    How may I change the email address that goes with my subscription?
    When I set up my original subscription, it was through an former employer.
    When I just bought some Skype credits, the confirmation page indicated that the verification email was to be sent to my old work email address.
    Thank You.

    Sign In to your account at www.skype.com and click on Account Settings
    then change Primary Email Address under Notification Settings
    Regards,
    Neil

Maybe you are looking for

  • Solution to Boot Camp partition failure due to: "some files can't be moved"

    I have had problems getting boot camp to partition my drive, reporting that "The disk cannot be partitioned because some files can't be moved." Solutions offered involve either backing up your entire drive and restoring it (SuperDuper), or defragging

  • Video Capture Filter Properties are not being save...

    So basicaly like I said in the title, I have to manualy go in to options and change all the settings so that the image from the camera is not to bright or too dark. Is there any way I could make this options get saved so next time I boot computer the

  • TweenMax a  Child symbol

    Hello everybody, this is my last try, then I will return to a brave tweening Designer. I asked a few times ago, but unforunately no solution at the end: I placed a symol on stage with a trigger at the first frame: sym.stop(); var eins = sym.createChi

  • SRM and QM

    Hi, I have been asked to look into a possible implementation of SRM with QM. Does anyone have any info on this. How would this work? Thanks, AR

  • Active/standby in multiple context mode

    is active/standby configuration possible in multilple context mode? i cannot find an article regarding this matter.