Return JSON from a CFC

I want to return login credentials in JSON format from a CFC. I am working on this, but don't think its right.

<cfcomponent name="loginCFC" displayname="loginCFC" output="false" hint="test login cfc for mobile app">
<cffunction name="getUser" access="remote" returnType="any" returnformat="JSON" output="false" hint="returns user info">
      <cfargument name="username" type="string" default="">
      <cfargument name="password" type="string" default="">

      <cfset var qGetUser = "">

      <cfquery name="qGetUser" datasource="#application.datasource#">
            select user_id, user_id_code, fname, lname, email
            from users
            where lower(email) = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.username#">
            and lower(password) = <cfqueryparam cfsqltype="cf_sql_varchar" value="#arguments.password#">
      </cfquery>

      <cfreturn qGetUser />
</cffunction>
theideabulbAsked:
Who is Participating?
 
Jones911Commented:
So ig you hit that cfc like http://url/cfc/loginCFC.cfc?method=getUser&username=a&password=b what do u get?
0
 
Jones911Commented:
What exactly do you want returned?
0
 
theideabulbAuthor Commented:
i want to return all the data that is in my query.
0
 
Jones911Commented:
Because it should work
0
 
theideabulbAuthor Commented:
HAHA! Your right it does work, i didn't try accessing it that way. I tried outputting it and dumping it.  Thanks.. Easy points for you :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.