Reputation: 83
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!
Upvotes: 3
Views: 307
Reputation: 1466
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.
Upvotes: 4
Reputation: 7519
Check the CF administrator. There is a setting labeled: Prefix serialized JSON with
. Turn that setting off.
Upvotes: 8