Updated to support nested objects and arrays