how to select a random value in a json array lua

Solutions on MaxInterview for how to select a random value in a json array lua by the best coders in the world

we are a community of more than 2 million smartest coders
registration for
employee referral programs
are now open
get referred to google, amazon, flipkart and more
register now
  
showing results for - "how to select a random value in a json array lua"
Samir
20 Apr 2017
1local open = io.open("array.json", "r")
2local string = open:read("a")
3local array = json.decode(string)
4open:close()
5local msg = array[math.random(1, #array)]