Solved

Return JSON from a CFC

Posted on 2011-03-01
5
494 Views
Last Modified: 2012-05-11
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>
0
Comment
Question by:theideabulb
  • 3
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Jones911
ID: 35013145
What exactly do you want returned?
0
 

Author Comment

by:theideabulb
ID: 35013154
i want to return all the data that is in my query.
0
 
LVL 19

Accepted Solution

by:
Jones911 earned 500 total points
ID: 35013209
So ig you hit that cfc like http://url/cfc/loginCFC.cfc?method=getUser&username=a&password=b what do u get?
0
 
LVL 19

Expert Comment

by:Jones911
ID: 35013210
Because it should work
0
 

Author Closing Comment

by:theideabulb
ID: 35013236
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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

PROBLEM:  How to open a cfwindow or run a function on double click of a cfgrid row. One of my clients wanted to be able to double click on a row item to get more detailed information about a transaction and to be able to modify the line items i…
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now