21 thoughts

  1. Wow, a lot of these new features are really coming as a surprise (to me at least.) Can’t wait to see what’s left to reveal. 🙂

  2. This is a great feature. I know quite a few developers who will be really happy about this, though it is a small change.
    Oh and once again, thanks for a great presentation last night.
    Mike.

  3. These are some great shorthand methods that we can finally use. Any consideration for adding another? Namely, ternary operators? That would be the cat’s knees. 🙂

  4. My, that second example is so… JSON-ish of you. 😀
    I love it. Pretty soon, I’ll have to do double-takes to make sure I’m looking at my JavaScript code or my CFScript code. 🙂

  5. Yep, John, that should indeed be structnew(). Good catch. I’m sure he was just writing the cf7 part of the example off the top of his head and hopefully will see these comments and correct it soon. Just confirming for you and other readers that you’re spot on.

  6. This seems a bit confusing to me how this is used.
    For example, would the code below automatically convert this string to a structure?
    <cfset myStructSTRING='{product="ColdFusion", version=8}’>
    <cfset myStruct=myStructSTRING>
    How would you go from a CFML struct back to the JSON string?

  7. Steve, I think perhaps you’re taking the reference to JSON by Joshua a little too literally. 🙂 It seems from the last part of your question that you’re saying confusion could come because someone getting such strings as JSON inputs might want to convert them into a CF array with this syntax, but that’s not what this feature is about. This is just about making it easier for CFML developers to create arrays and structs in a short-hand notation in traditional CFML code. There’s no connection to JSON in it at all. Joshua was just saying it seems *like* JSON.
    What you’ve shown is just a simple assignment, and naturally, any quoted string on the right side of an assignment becomes a string in the left hand variable, and your string remains so in both assignments. (I suppose perhaps if this was a function, it might be able to take a string and coerce it into something else. )
    I’ll leave it to others with more experience in the new JSON functionality in Scorpio to elaborate on whether your desired conversion (either direction) might be done with some other new functionality (if it can yet be discussed publicly). Hope that’s helpful.

  8. Charlie, you are right, this isn’t JSON, it had me fooled! But indeed, it is not. It seems odd to me that they would make something that is ‘close’ but not the same as fairly standardized syntax. Sounds like a Microsoft thing to do.
    It’s even more bizarre that you’re saying CF8 (may?) have direct support for JSON *and* this almost-JSON syntax.
    CF8:
    {product="ColdFusion", version=8}
    vs:
    JSON:
    {"product" : "ColdFusion", "version" : 8}
    Why two different variations? Ben any thoughts?

  9. Steve and Charlie: You know, if you could that code and turn it into this:
    <cfset myStructSTRING='{product="ColdFusion", version=8}’>
    <cfset myStruct=Evaluate(myStructSTRING)>
    That would blow my mind! 😀 I’m not even sure if that would be useful, but it would be cool. 🙂

  10. Steve, as for me referring to CF8 and JSON, I’m only saying that there have been many public mentions of new JSON-oriented functionality coming in Scorpio (google for the keywords scorpio json), but am not meaning to propose anything more than what’s been offered publicly. I was just saying that there MAY be some other solution for what you (and Joshua) sought. Perhaps Ben or others can speak to that. But it may be that even if there is, it’s not yet public. Not trying to be cryptic. Just being frank.

  11. John, you are correct, I missed the (). That’s what happens when I blog in an airport about to board a flight. 😉 Thanks for pointing it out!
    — Ben

  12. One question though – currently you have shown {product="ColdFusion", version=8} notice that for example – product = "coldfusion" the equals sign, shouldn’t this be a colon ie – product: coldfusion ?
    This is how object literals work in other languages, isn’t that what CF8 is trying to allow?

  13. James, my answer would be "no, and heck no". 🙂
    First, let me say that I couldn’t get it to work as you propose. Now, you were missing a closing quote before your closing brace, but that’s not the reason. I first used that new script-based struct-building code to create a struct, and confirmed it worked (dumped the struct it created). I then tried to use the same right-hand code (the brace-enclosed code) from that assignment to put into the ArgumentsCollection. It failed to compile. I tried all forms of quotes and pounds, to no avail.
    I also tried to put it in the VAR attribute of CFDUMP. It just wouldn’t work. I also tried using evaluate. Maybe someone else can find a way to make it work.
    Even then, the "heck no" part of my reply is that I surely don’t hope to see this style catch on. 🙂 Building a struct within an attribute of a tag this way seems very unusual, at least to a CF developer’s eyes. I realize you’re saying it seems flex-y. Still, I’d ask it it’s really solving any problem or perhaps just creating more confusion. That’s just my opinion, of course.

  14. So, this combined with the argumentscollection property should let us do something like the following? :
    <CFQUERY ARGUMENTSCOLLECTION="{name="myQuery", datasource="myCSN} ">

    </CFQUERY>
    (btw, I’m not a cf developer. Mostly flex, and from the looks of it, this is closer and closer to what I’m familiar with)

Leave a Reply to John Farrar Cancel reply