Is there a way to escape pound character (#) in ColdFusion?

Viewed 3486

I have a function in a CFC file that takes a JSON string as an argument. The function then uses the deserialized data to execute an UPDATE query. In the the JSON string, one of the properties has the character # as part of the name. This character makes the code to break in ColdFusion because it is interpreted as a variable. Is there any way to make ColdFusion "escape" that character and consider it just a string? Remember that is part of JSON string.

Below is my function. It doesn't allow me to access dnisObject because of the # characters within the JSON string. If I delete those # from the JSON string it works fine. Those values have to be stored in a database with the #, so I can not just delete them completely.

<cffunction name="updateDnisHproduct" access="remote">
    <cfargument name = "lid" type = "numeric" required = "yes">
    <cfargument name = "updatedObj" type = "string" required="yes">


    <cfset dnisObject = DESERIALIZEJSON(arguments.updatedObj)/>

    <cfset test =[{"phone":"1001106672","lineType":"Outbound","label1":"Voicemail for line #54940","label4":"test","hcat":"18","freshStart":"0","phoneCode":"","hproduct":"3","checked":false},{"phone":"1001106672","lineType":"Outbound","label1":"Voicemail Line Box #58940","label4":"12","hcat":"54","freshStart":"0","phoneCode":"","hproduct":"12","checked":false}'>

    <cfset dnisObject = DESERIALIZEJSON(test)/>
</cffunction>
2 Answers
Related