?
Solved

Return JSON from a CFC

Posted on 2011-03-01
5
Medium Priority
?
507 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 2000 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

Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

770 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