Created
September 4, 2023 13:30
-
-
Save judepereira/f9252d8505d9da3f6cb5963ea2f576e1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static String escapeString(Object o) { | |
if (o == null) { | |
return null; | |
} | |
String str = o.toString(); | |
if (str.contains("\\")) { | |
str = str.replace("\\", "\\\\"); | |
} | |
if (str.contains("\"")) { | |
str = str.replace("\"", "\\\""); | |
} | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment