I'm trying to parse a json file and ran into this issue. I'm pulling some data out of a query and converting it into a json, sending it to another file, and then parsing it. However some of the data is an empty string, and that breaks stuff when I try to parse it.
I am currently generating the json object like so:
<cfset person = '{
"fname":"#ReReplace(firstName, '\t', '\\t', "all").trim()#",
"lname":"#ReReplace(lastName, '\t', '\\t', "all").trim()#",
"occupation":"ReReplace(lastName, '\t', '\\t', "all").trim()#"
}'>
I am currently already using replace to handle tabs in the values (don't ask, people do weird stuff) and would like to use replace to handle empty strings. I tried using Replace(firstName, '', '""', "all")
but coldfusion didn't like that one bit, for pretty obvious reasons. One option would be to use an if statement before I get to the json generation, but I'm wondering if anyone knows of a quicker way using Replace
?