title: How to compare two JSON requests?
body: <p>Short Story: How can I compare two chunks of JSON? The code below errors out.</p>
  
  <pre><code>var j, j2 interface{}
  b := []byte(srv.req)
  if err := json.Unmarshal(b, j); err !=nil{
      t.Errorf("err %v, req %s", err, b)
      return
  }
  d := json.NewDecoder(r.Body)
  if err := d.Decode(j2); err !=nil{
      t.Error(err)
      return
  }
  if !reflect.DeepEqual(j2, j){
      t.Errorf("j %v, j2 %v", j, j2)
      return
  }
  </code></pre>
  
  <p>Long Story:
   I'm doing some E2E testings and part of this I need to compare the requested JSON body with the received JSON. To do this I've tried to unmarshal the expected and received json to an empty interface (to avoid any type mistakes) but I get an error:
  <code>json: Unmarshal(nil)</code>. I guess encoding/json doesn't like the empty interface so the question is how can I compare two chunks of JSON? A string comparison would be error prone so I'm trying to avoid that.</p>