If I have a list of object strings containing field data for an object and I have a parameter selecting which object this should be inserted into, is it possible to write apex to insert those records? From what I understand you need to know the object type upfront so you can do something like this...
//example data
myJSONArr = [{"Subject":"val1","Description":"val2","Status":"val3","Origin":"val4"},{"Subject":"val5","Description":"val6","Status":"val7","Origin":"val8"},{"Subject":"val9","Description":"val10","Status":"val11","Origin":"val12"},{"Subject":"val13","Description":"val4","Status":"val5","Origin":"val16"}]
//for Each object element
Case newCase = (Case)JSON.deserialize(myJSONObject, Case);
But is there a way if I had a string with the object name I couldn't somehow...
String selectedObjectToInsert = Case;
<selectedObjectToInsert> = JSON.deserialize(myJSONObject, selectedObjectToInsert);
What should I be looking for to do this sort of dynamic object creation? The end goal is to take the select object, the JSON array of the object fields and values, and insert them into Salesforce.