I'm developing web app using coldfusion. When client send a request to the app, the app needs to send response back with JSON object. So I'm trying to display JSON object but I'm getting two slash "//" before my JSON object. That's why when I use isJSON function, it returns NO.
Here is the code I'm using in coldfusion:
<cfset usr_result= StructNew() />
<cfset usr_result = {'result'='success', 'type'='new'}>
<cfset json = SerializeJSON(usr_result)>
<cfoutput>
#json#
#isJson(json)#
</cfoutput>
Output is:
//{"result":"success","type":"new"} NO
I'm expecting
{"result":"success","type":"new"} YES
Any suggestions?
Thank you!
Check the CF administrator. There is a setting labeled: Prefix serialized JSON with. Turn that setting off.
In addition to turning off the JSON prefix at the server level, you can turn off the prefix at the application level. In your application.cfc, you can add this.secureJSON = false to turn off the prefixing of the JSON string.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With