0 Replies Latest reply on May 8, 2013 2:44 AM by playedinane

    Restful service returning components

    playedinane

      Is there any way, or indeed am I doing something wrong when creating my components, to get components to generate json consistently. The json I'm returning will have the first letter capitalized and the rest lower case when returning the component from the restful service however all capitalized when calling the compoent remotely.

       

      Some demo components as below:

       

      User.cfc

       

      component {

           property type="numeric" name="userid";

           property type="string" name="username";

      }

       

      Users.cfc

      component output="false" restPath="/users"

      {

           remote User function getByPK(required numeric id restArgSource="Path") output="false" httpMethod="GET" restPath="{id}"

           {

                user = new user();

       

                user.userid = 1;

                user.username = "Chicken";

       

                return user;

           }

      }

      Output:

      /rest/users/1.json

      {"Username":"Chicken","Userid":1.0}

      /rest/users/1.xml

      <COMPONENT ID="1" NAME="User">

      <PROPERTY NAME="USERNAME" TYPE="STRING">Chicken</PROPERTY>

      <PROPERTY NAME="USERID" TYPE="STRING">1</PROPERTY>

      </COMPONENT>

       

      /Users.cfc?method=getByPK&id=1&returnFormat=json

      {"USERNAME":"Chicken","USERID":1}

       

      Is this simply a quirk I have to put up with?