Thanks to Keith C. I have my solution for the overall aspect of what I was doing. Here is the almost completed class. I leave some for you to do but this covers a large portion. Hope it helps others out there.
This class allows for a field Mapping reference between a SObject and a class structure and then loads the class structure based on data from the SObject, can easily be done the other way also with some modification.
public class myClass{
public string name;
public Date currentDate;
public string email;
}
public Set<String> getAttributes() // found example here on stackExchange
{
myClass m = new myClass();
// Serialize out Ojbect into JSON
String s = JSON.serialize(m);
// Deserialize it back into a key/value map
Map<String,Object> obj = (Map<String,Object) JSON.desializeUntyped(m);
// Return a Set of those fields present on our object
return obj.keyset().clone();
}
// build an sObject to myClass field name map
// Acutal not shown sorry
{
Map<String,String> fieldMap = new Map<String,String>();
fieldMap.put(sObjectFieldName, structureFieldName);
// this puts sObject fields and maps them to myClass Structure fields
}
public myClass loadValues{
// Get Data from SObject based on fieldMap
// Actual Not shown sorry
List<SObject> sObjects = [SELECT id, name FROM SObject];
for(SObject s : SObjects){
Map<string, string> structMappedValues = new Map<string,string>();
myClass mc = new myClass();
for(String field : fieldMap ){
structMappedValues.put(fieldMap.get(field), (string)s.get(field))
}
//Thanks Keith C - convert mapped field and data to class struct
mc = (myClass) JSON.deserialize(JSON.serialize(structMappedValues),myClass.class);
}
return mc;
}