title: How to change json response to string using ruby code
body: <p>i am new with ruby code, so i have this response :</p>
  <pre><code>{
     &quot;data&quot;:[
        {
           &quot;name&quot;:&quot;Andy&quot;,
           &quot;user_type&quot;:0,
           &quot;info&quot;:&quot;&quot;,
           &quot;user_info&quot;:null,
           &quot;new&quot;:false,
           &quot;active&quot;:false,
           &quot;cities&quot;:[
  
           ],
           &quot;visibility_settings&quot;:{
              &quot;general&quot;:false,
              &quot;product&quot;:false
           }
        }
     ]
  }
  </code></pre>
  <p>how to change it to_string in ruby code, like this</p>
  <pre><code>&quot;name&quot;:&quot;Andy&quot;,
  &quot;user_type&quot;:&quot;0&quot;,
  &quot;info&quot;:&quot;&quot;,
  &quot;user_info&quot;:&quot;null&quot;,
  &quot;new&quot;:&quot;false&quot;,
  &quot;active&quot;:&quot;false&quot;,
  &quot;cities&quot;:&quot;[]&quot;,
  &quot;visibility_settings&quot;:{
  &quot;general&quot;:&quot;false&quot;,
  &quot;product&quot;:&quot;false&quot;
  }
  </code></pre>
  <p>because i want to compare it with my datatable :</p>
  <pre><code>| name    | user_type | new   | user_info |
  | Andy    | 1         | false | true      |
  </code></pre>
  <p>and my script is like this :</p>
  <pre><code>And(&quot;response &quot;jsonpath&quot; filter &quot;filter&quot; have:&quot;) do |jpath, filter, table|
        response = JsonPath.new(&quot;#{jpath}&quot;).on(@response).to_a.first
        table = table.hashes
        table.each do |data|
          target = response.select { |resp| resp[&quot;#{filter}&quot;] == data[&quot;#{filter}&quot;] }   data.each { |key, value| expect(data).to eq(target.first) }
        end
      end
  </code></pre>