title: Convert a string which is a key value pair to hash in ruby
body: <p>I am having problem to manipulating a key value pair of string to hash in ruby.The string is:</p>
  
  <pre><code>"specialties":["Corporate Housing","Temporary Housing","Furnished Apartment","Short Term Rentals"],"website":"http://www.demo.com","universalName":"some-corporate-housing","size":"51-200 employees","description":"demo description","industry":"Hospitality","companyType":"Privately Held","companyName":"some Corporate Housing","includeSecondAd":true,"yearFounded":1995,"headquarters":{"city":"Austin","zip":"78759","state":"Texas","street1":"9606 N. Mopac Expressway","country":"United States","street2":"Suite 500"},"homeUrl":"https://www.some.com/company/some-corporate-housing"
  </code></pre>
  
  <p>remember it's an string.Now i would like to make a hash like below:</p>
  
  <pre><code>"specialties":["Corporate Housing","Temporary Housing","Furnished Apartment","Short Term Rentals"],
  
  "website":"http://www.demo.com",
  
  "universalName":"some-corporate-housing",
  
  "size":"51-200 employees",
  
  "description":"demo description",
  
  "industry":"Hospitality",
  
  "companyType":"Privately Held",
  
  "companyName":"some Corporate Housing",
  
  "includeSecondAd":true,
  
  "yearFounded":1995,
  
  "headquarters":
  
    {"city":"Austin",
     "zip":"78759",
     "state":"Texas",
     "street1":"9606 N. Mopac Expressway",
     "country":"United States",
     "street2":"Suite 500"
    },
  
  "homeUrl":"https://www.some.com/company/cws-corporate-housing"
  </code></pre>
  
  <p>I have searched alot and used <code>split</code> method of <code>ruby string</code> class.Like bellow:</p>
  
  <pre><code># test reffers to the string .
  hash = {}
  test.split(',').each do |pair|
  
          key,value = pair.split(/:/) 
          hash[key.to_sym] = value
  end
  </code></pre>
  
  <p>this gives me a wrong hash.like bellow:</p>
  
  <pre><code>hash["specialties"] #=&gt; "Corporate Housing",
  </code></pre>
  
  <p>as <code>specialties</code> is an array it should have all the values but it's only returning the first value.</p>
  
  <p>I can not understand how to convert this string into proper hash.
  Please help me guys.</p>
  
  <p>Thanks so much in advance.</p>