I'm using v31.0 of the Salesforce REST API. When looking at the metadata for some of my objects, Salesforce says that the OwnerId field references two tables: Group and User. The JSON that Salesforce returns looks like this:
... referenceTo: [ "Group", "User" } ....
How can I tell which type of object to grab the Name value from? For example, for fields not referencing multiple types, I simply take the referenced object, and put it in a query to find the name value.
'select name from ' + referenceTo
How can I find out this information when the field is referencing multiple types?