+ Start a Discussion
SandrineSandrine 

Always have \ characters before double quote


Hello,

I have a code pice like below
If(String.isNotBlank(StringFieldNAME)){
            If(StringFieldNAME.Contains(';')){
                StringFieldNAME = '["'+StringFieldNAME.replaceAll(';','", "')+'"]';
            }            
        }

In the putput of JSON, i have like this
"[\"J\", \"L\", \"M\", \"N\"]"

But My Expectations is 
"["J", "L", "M", "N"]"

How can i do it ?
Best Answer chosen by Sandrine
AnudeepAnudeep (Salesforce Developers) 
Can you try the following?
String s = StringFieldName.replaceAll('\','');

If that does not help, I suggest removing all special characters

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!

Anudeep

All Answers

AnudeepAnudeep (Salesforce Developers) 
Can you try the following?
String s = StringFieldName.replaceAll('\','');

If that does not help, I suggest removing all special characters

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!

Anudeep
This was selected as the best answer
SandrineSandrine
When i use it, i have error message
Unrecognized symbol '"', which is not a valid Apex identifier.