I'm trying JSON Parser and in the JSON I've \"
(for like <tag style=\"color: #fff;\"...
)
If I can replace \"
with \\"
the parser works fine (like in this – https://developer.salesforce.com/forums/?id=906F000000092v4IAA)
Input {"name":"Surya\".\""} like name = Surya"."
Output {"name":"Surya\".\""}
String input = '{"name":"Surya\".\""}';
System.debug( input );
//String output = input.replace('\"', '\\\"');
String output = input.replaceAll('\\\"', '\\\\\"');
System.debug( output );
I tried with replace & replaceAll.
Please advice me. Thanks.
Best Answer
If one of the value strings in your JSON is encoded, the simplest and most reliable way to decode is to use a deserialize call:
For your example something like: