added MaxDepth option. if don't have this option then an infinite loop occurs in nested objects.