6 Replies Latest reply on Nov 7, 2012 7:18 AM by PeteComcar

    Why do Coldfusion structure key cases change depending on declaration style?

    PeteComcar
      In this simple component (test.cfc):

       

      component {

       

           VARIABLES.obj = {};

           VARIABLES.obj.foo = "bar";

           VARIABLES.obj['foo2'] = "bart";

       

          remote function func1() {

              return VARIABLES.obj;

          }

      }

      The response from the URL “/test.cfc?method=func1&returnformat=json” looks like this:

      {
      • foo2: "bart",

      • FOO: "bar"

      }

       

      Note that if you declare the property of a structure with dot notation, it is returned in uppercase. Using array like declarations returns it as you specified.

       

      This is still apparent when dumping a structure in a page, but is more of a problem when accessing the results via JSON in a Javascript appliation, as this is case sensitive.

       

      Pete