Created
September 10, 2019 21:14
-
-
Save trycf/ac76977333095bf4c349432d7b7bad9a to your computer and use it in GitHub Desktop.
TryCF Gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--- 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