function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
AbAb 

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 Ab
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
AbAb
When i use it, i have error message
Unrecognized symbol '"', which is not a valid Apex identifier.