Created
July 30, 2015 16:23
-
-
Save levonlee/e8aada95114acf0208e6 to your computer and use it in GitHub Desktop.
Convert ColdFusion Variable to JSON and Output
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
<!--- Convert a ColdFusion variable to JSON format ---> | |
<cfset s = "I'm a string or URL."> | |
<cfset numInteger = 1994> | |
<cfset JSONUtil = createObject("component","functions.JSONUtil")> | |
<cfoutput>#JSONUtil.serializeJSON(s)#</cfoutput> | |
<cfoutput>#JSONUtil.serializeJSON(numInteger,0,1)#</cfoutput> | |
<!--- Read json ---> | |
<cfset strJson = ' {"strerror":"","strsuccess":"Thank you for your message!"}'> | |
<cfset JSONUtil = CreateObject("component","functions.JSONUtil") /> | |
<cfset myCFvar= JSONUtil.deserializeFromJson(strJson)> | |
<cfdump var="#myCFvar#"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment