title: Need to print all the values in the nested hash
body: <p>I have a hash which has many hash inside and the value may be an array and this array consist of many hashes, I wanted to print all key value pair, If values is array, then it has to print </p>
  
  <pre><code>"pageOfResults": "Array" # I don't want actual array here, I want the string "Array" to be printed. 
  </code></pre>
  
  <p>Of If hash follows, then it needs to print </p>
  
  <pre><code>"PolicyPayment": "Hash"
  </code></pre>
  
  <p>else It needs to print key and value</p>
  
  <pre><code>Key  -&gt; "CurrencyCode": 
  Value-&gt; "SGD",
  </code></pre>
  
  <p><em>Hash follows</em></p>
  
  <pre><code>a={
      "PageOfResults": [
          {
              "CurrencyCode": "SGD",
              "IpAddress": nil,
              "InsuranceApplicationId": 6314,
              "PolicyNumber": "SL10032268",
              "PolicyPayment": {
                  "PolicyPaymentId": 2188,
                  "PaymentMethod": "GIRO"
              },
              "InsuranceProductDiscountDetail": nil,
              "ProductDetails": {
                  "Results": [
                      {
                          "Id": 8113,
                          "InsuranceProductId": 382,
                          "ApplicationProductSelectedId": 62043,
                      },
                      "InsuranceProduct": {
                          "InsuranceProductId": 382,
                          "ProductCode": "TL70-90",
                      },
                  ],               
              },
          }
      ]
  }
  </code></pre>
  
  <p>Program I have written to print these values</p>
  
  <pre><code>a.each do |key,value|
      puts "key-&gt;" + key.to_s
      if value.is_a?Array
          value.each do |v|
              v.each do |key,value|
                  puts "key-&gt;"+key.to_s
                  puts "value-&gt;"+value.to_s       
              end
          end
      else
          puts  "value-&gt;"+value.to_s
      end
  </code></pre>
  
  <p>This program is printing first of level of hash and it's values, I can do recursive calls to print all values as well, </p>
  
  <p>But my question is, Is there any way we can write Ruby style of code to accomplish this easily? Or any better way?</p>