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 the UPDATE query. In a JSON string, one of the properties has a character #as part of the name. This character causes code to break in ColdFusion because it is interpreted as a variable. Is there a way to make ColdFusion "escape" from this character and consider it just a string? Remember that this is part of the JSON string.
Below is my function. This does not allow me to access dnisObjectdue to characters #in the JSON string. If I remove those #from the JSON string, it works fine. These values should be stored in the database using #, so I cannot 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>
source
share