Handle potential array keys in serialization