Activity Forums Salesforce® Discussions Converting Salesforce sobject List into string List Reply To: Converting Salesforce sobject List into string List

  • sushant

    Member
    January 16, 2017 at 2:27 pm

    Hi Vikas,

    This example can help you:

    public class GetRestfulExampleSu{

    public string jsonStr {get;set;}
    public Pagereference getJSONFromREST() {
    Http h = new Http();
    HttpRequest req = new HttpRequest();
    req.setEndpoint('http://dz.co.rplug.renault.com/localsemiclair/BAWn');
    req.setHeader('Accept','application/JSON');
    req.setMethod('GET');
    HttpResponse res = h.send(req);
    jsonStr= res.getBody();

    system.debug('jsonStr>>>>-->>>>>>'+jsonStr);

    jsonStr= res.getBody();

    Map<String,Object> rawObj = (Map<String,Object>) JSON.deserializeUntyped(jsonStr);

    Map<String,Object> responseObj = (Map<String,Object>)rawObj.get('localSemiClair');
    Map<String,Object> responseObjinside2 = (Map<String,Object>)responseObj.get('mapRepresentation');
    Map<String,Object> responseObjinside3 = (Map<String,Object>)responseObjinside2 .get('map');

    List<Object> reqs = (List<Object>) responseObjinside3.values();
    List<string> lsstr= new List<string> ();

    for(Object a: reqs){
    lsstr.add(String.valueOf(a));
    }

    return null;
    }

    }

    Thanks