Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8464161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:39:25+00:00 2026-06-10T14:39:25+00:00

Using the array notation for creating the keys in a struct used to preserve

  • 0

Using the array notation for creating the keys in a struct used to preserve the case of the key.

<cfset var response = structNew()>
<cfset response[ "error" ] = 0>
<cfset response[ "message" ] = "">
<!--- this worked when converting this struct to a JSON

So when I actually put some data into the struct:

<cfset response.error = 1>
<cfset response.message = "There was an error inserting the record...">

I surprised when I saw this come across the firebug console:

{"MESSAGE":"There was an error inserting the record...","ERROR":1}

note, the information is what I was expecting to see.

I understand if I would have used <cfset response.error = 0>, for the case not to be preserved when converting it to a JSON, but this has worked for me in the past. Am I doing something wrong that I’m blind to or did something change in CF10?

EDIT:

Before all of the responses came back, I tried what everyone said.

<cfset response["error"] = 1>
<cfset response["message"] = "There was an error inserting the record...">

and it worked. So, I’m guessing they changed how serializeJSON works in CF10.

Good to know.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T14:39:27+00:00Added an answer on June 10, 2026 at 2:39 pm

    If you continue to reference the struct key with bracket notation rather than dot notation, you should have no issue with case when using serializeJSON().

    After testing on CF9, however, it seems to work fine whether I use bracket- or dot-notation. This may be a difference between CF9 and 10 and, as Ray recommends, you may want to file a bug report for it.

    Here’s what I did in CF9:

    <cfset response = structNew()>
    <cfset response[ "error" ] = 0>
    <cfset response[ "message" ] = "">
    <!--- this worked when converting this struct to a JSON --->
    
    <cfoutput>#serializeJSON(response)#</cfoutput><br /><br />
    
    <!--- This outputs {"message":"","error":0} --->
    
    <cfset response.error = 1>
    <cfset response.message = "There was an error inserting the record...">
    
    <cfoutput>#serializeJSON(response)#</cfoutput>
    <!--- This outputs {"message":"There was an error inserting the record...","error":1} --->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using array as an associative array of objects in which keys are
In PHP, you can initialize arrays with values quickly using the following notation: $array
I know I can slice a string in Python by using array notation: str[1:6]
Using JavaScript it's possible to access an object using the dot notation or array
I'm trying to get better at using pointers, and not using array notation. So
For a 4-D array, I'm trying to average the values using compact pointer notation.
When I need to declare a new array I use this notation var arr
Is there a way to create an array of Fixnums using ruby's % notation?
I am creating a list item on the fly using the object notation (
I am using Array() with each_with_index to output a array with index but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.