I have a JSON response object that contains an array, the array only ever contains one value. I want to map the result of to a field in a salesforce object.
I have a response class with an Array called State :
public class JobResponse{
public string uuid {get; set;}
public datetime startedOn {get; set;}
public string description {get; set;}
public datetime completedOn {get; set;}
public string jobId {get; set;}
public JobLead jobLead {get; set;}
public datetime scheduledOn {get; set;}
public datetime createdOn {get; set;}
public list <State> state {get; set;}
public Signature signature {get; set;}
public customField customFields {get; set;}
public Location location {get; set;}
}
public class State {
public string state{get; set;}
}
but i'm not sure how to map the result of the array to a field:
JobResponse jobresp = (JobResponse)JSON.deserialize(res.getBody(), JobResponse.class);
sc.FieldAwareId__c = jobresp.uuid;
sc.FA_Job_ID__c = jobresp.jobId;
sc.State__c = jobresp.State.state;
How would I map the jobresp.State.state response to a the sc.State__c field?
My example gives me an error: Initial term of field expression must be a concrete SObject: List