Answers for "hash to string in ruby"

2

convert string to hash ruby

hash_as_string = 
	"{\"0\"=>{\"answer\"=>\"1\", \"value\"=>\"No\"}, 
    \"1\"=>{\"answer\"=>\"2\", \"value\"=>\"Yes\"}, 
    \"2\"=>{\"answer\"=>\"3\", \"value\"=>\"No\"}, 
    \"3\"=>{\"answer\"=>\"4\", \"value\"=>\"1\"}, 
    \"4\"=>{\"value\"=>\"2\"}, \"5\"=>{\"value\"=>\"3\"}, 
    \"6\"=>{\"value\"=>\"4\"}}"
JSON.parse hash_as_string.gsub('=>', ':')
Posted by: Guest on September-10-2021

Browse Popular Code Answers by Language