Correctly handle empty objects and arrays