fork download
  1. require "json"
  2.  
  3. value = "[{\"a\":\"test a\"},{\"b\":\"test b updated\"}]"
  4.  
  5. arr = JSON.parse(value)
  6. combined_hash = arr.reduce({}, &:merge)
  7. puts combined_hash.to_json
Success #stdin #stdout 0.06s 10408KB
stdin
Standard input is empty
stdout
{"a":"test a","b":"test b updated"}