I have an array like so:
[
[0] {
"Success" => true
},
[1] {
"Success" => true
},
[2] {
"Success" => true
},
[3] {
"Success" => true
}
]
Each number above has a much larger multidimensional array associated with it, but that is not my concern currently. I am wanting to rename the numbers [0..3] with new key values.
So it would look like this
[
["pop"] {
"Success" => true
},
["rock"] {
"Success" => true
},
["country"] {
"Success" => true
},
["soul/r&b"] {
"Success" => true
}
]
Thanks in advance!
if your input is really JSON, you need to first parse the JSON and convert it into a Ruby data structure:
Now your input is a Ruby Array…
I assume you have the new keys stored in an array somewhere like this:
Next step is to replace the first element of each of the sub-arrays in the JSON array with the new key: