java - What's the right way to escape a string before writing it to an Apache Commons PropertiesConfiguration? -


We have a ".properties" file that has some values ​​remaining as JSON I have been bitten by special characters, Although - org.json.JSONObject is very important because it causes throats, so it is always to find out that I wrote {"key": "this one \" value \ ""} , but I read {"key": "this is a" value ""} . Obviously, the latter is going to fit the JSON Parser. Rather than attempting to knock it by trial and error, someone can tell me that any right method (which is the complete JSON string at all in this case) to avoid the value before passing it Property configuration class to be written in the file?

Backslash is ignored in property files You need to use Unicode encoding in this way,

  "This is a \ u005c" value \ u005c " 

Comments