Ask a Question
Ask Question Login
Corporate Training
  1. Community
  2. Salesforce
  3. Question
Salesforce

How to convert an object to a salesforce list class?

Asked by Dipika Agarwal May 12, 2023 1.8K views 1 answer
Share

About this question

 I have an object with value (s1,s2,s3,s4) (this is the value I get during System.debug). Now I want to convert these values to a list of strings, i.e ['s1','s2','s3','s4'].
How can I do that?

I tried,

List test = new List(); test.addAll((List)obj); // threw an error can't convert List to List
List test = new List(); test.addAll((List) JSON.deserializeUntyped(obj.toString())); // throws Unexpected character ('(' (code 40)): expected a valid value (number, String, array, object, 'true', 'false' or 'null') at input location [1,2]

Your answer

1 Answer