Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save trycf/ac76977333095bf4c349432d7b7bad9a to your computer and use it in GitHub Desktop.
Save trycf/ac76977333095bf4c349432d7b7bad9a to your computer and use it in GitHub Desktop.
TryCF Gist
<!--- DEMO data (CFML style) --->
<cfset getFAQs = QueryNew("Tags,Question,Answer"
, "varchar,varchar,varchar"
, [ {"tags": "already transferred"
, "question": "Can we transfer customers who have already been transferred previously? what is the dispo? warm transfer or already contacted?"
, "answer": "Yes, mark as already contacted."
}
,
{
"tags": "secured debt"
, "question": "If customer only has secured debts, can we still offer credit repair?"
, "answer": "Yes, as long as they have at least $100 in secured/unsecured debt.
"
}
])>
<!--- build array of structures --->
<cfset yourArray = []>
<cfloop query="getFAQs">
<cfset yourArray.append( { "tags" : getFAQs.tags
, "question" : getFAQs.question
,"answer": getFAQs.answer
} )>
</cfloop>
<!--- format as JSON --->
<cfset jsonString = serializeJSON( yourArray )>
<!--- DEMO - display results --->
<cfoutput><code>#jsonString#</code></cfoutput>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment