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
Vetriselvan ManoharanVetriselvan Manoharan 

Need help with the code

Hi,

I need to get list of user names and return a string like below

['first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth']



Thanks,
Vetri

 
Best Answer chosen by Vetriselvan Manoharan
Shrikant BagalShrikant Bagal
Hello Vetriselvan,

You can use JSON Class Methods of Apex:

Please try following Code:
 
public String getUserNames(){
   List<Stribng> lstuserName = new List<String>(){ 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth' };
        return JSON.serialize(lstuserName);
}
If its helps, please mark as best answer so it will help to other who will serve same problem.
T​hanks! 
 

All Answers

Shrikant BagalShrikant Bagal
Hello Vetriselvan,

You can use JSON Class Methods of Apex:

Please try following Code:
 
public String getUserNames(){
   List<Stribng> lstuserName = new List<String>(){ 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth' };
        return JSON.serialize(lstuserName);
}
If its helps, please mark as best answer so it will help to other who will serve same problem.
T​hanks! 
 
This was selected as the best answer
Shrikant BagalShrikant Bagal
Hello Vetriselvan,

Please try following code:
 
public String getUserNames(){
   List<String> lstuserName = new List<String>(){ 'first', 'second', 'third', 'fourth', 'fifth', 'sixth', 'seventh', 'eighth', 'ninth', 'tenth' };
        return JSON.serialize(lstuserName);
}