JuMP array or dictionary lookups

Is it possible to look up values in an array or a dict using integer variables?
Something like

@variable(model, x, Int)
# restrict x to appropriate values
@constraint(model, my_array[x] <= 5)

Or should a binary array with a single one be created and summed over to implement the look up? Like:

@variable(model, x[1:n], Bin)
@constraint(model, sum(x[i] for i in 1:n) ==1)
@constraint(model, sum(x[i]*my_array[i] for i in 1:n) <= 5)

Is this where you use something like MOI.SOS1? Can you use SOS1 on an array of arrays?

You should use the binary approach.

You could also use an SOS1 over x. But the performance is likely similar.