Check for objects as well as arrays in the add field method