Make array decoding generic