Coast Line
asked on
Problem with the Data
Hi, I have the data coming from the database, and that data has the all kinds of special characters, My data is going back to the Page through JSON, I am using the JSStringFormat but still that is failing somewhere!
"#jsStringFormat(ReReplace (myString, '[\r\n\t"]+', '', 'ALL'))#"
if it encounter single quote, it will wreck the JSON! and also how i do use the above rerplace to skip the double quotes and single quotes and replace with some other character or something should be done like htmleditformat so it should not the break the data
I Just tested with single quotes and it breaked, but i do not know if this will break on any other characters.
Please guide me Thanks
"#jsStringFormat(ReReplace
if it encounter single quote, it will wreck the JSON! and also how i do use the above rerplace to skip the double quotes and single quotes and replace with some other character or something should be done like htmleditformat so it should not the break the data
I Just tested with single quotes and it breaked, but i do not know if this will break on any other characters.
Please guide me Thanks
Can you give an example of a before text and an after text?
ASKER
like >>
This is the one feature's i have been testing!
The above line is coming from database so if it encounters the 's, it breaks the JSON which is sent to the Browser! I am not sure but there might be Other Special Characters like!
Double Quotes, Special Characters, etc
This is the one feature's i have been testing!
The above line is coming from database so if it encounters the 's, it breaks the JSON which is sent to the Browser! I am not sure but there might be Other Special Characters like!
Double Quotes, Special Characters, etc
I think \r\n will not work.
try to replace #chr(13)# and #chr(10)#
try to replace #chr(13)# and #chr(10)#
ASKER
well i need to skip the
/r/n/t\' etc tags and they may be repetitive, please give a valid regex for this
/r/n/t\' etc tags and they may be repetitive, please give a valid regex for this
i think Regex cant handle that, try:
<cfset searchlist = '#chr(13)#,#chr(10)#,#chr( 9)#,"'>
<cfset replacelist = ",,,">
#jsStringFormat(Replacelis t(myString , searchlist, replacelist))#
(not tested)
<cfset searchlist = '#chr(13)#,#chr(10)#,#chr(
<cfset replacelist = ",,,">
#jsStringFormat(Replacelis
(not tested)
Based on what I find here: http://code.google.com/p/json-simple/wiki/EscapingExamples
My guess is that you would need something like:
My guess is that you would need something like:
"#jsStringFormat(ReReplace(myString, '(["/\\\b\f\n\r\t]|\u[a-fA-F0-9]{4})', '\\\1', 'ALL'))#"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@dagaz_de
Thank for your code, but an u explain a bit, is seems doing toomany thigs in a singe command!, i do want to replace comma as it does not break json!
@ kaufmed Can u please explain your code what strings or specil characters in handles and how!
Thanks
Thank for your code, but an u explain a bit, is seems doing toomany thigs in a singe command!, i do want to replace comma as it does not break json!
@ kaufmed Can u please explain your code what strings or specil characters in handles and how!
Thanks
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Guys