Skip to content Skip to sidebar Skip to footer

Removing "\" In Json Object String

How can i remove special character '\' in the string below: String x = { 'message': { '@content': 'toom' }, 'recipients': '[{\'@id\':\'1000001865\'}]', 'roo

Solution 1:

You must escape the backslash in the regex.

try

x.replaceAll("\\\\", "")

see JavaRegularExpressions: 3.6. Backslashes in Java

Post a Comment for "Removing "\" In Json Object String"