title: Check if struct field is empty
body: <p>I would like to iterate over the fields of a <code>struct</code> after unmarshalling a JSON object into it and check for the fields whose value was not set (i.e. are empty).</p>
  
  <p>I can get the value of each field and compare that to the <code>reflect.Zero</code> value for the corresponding type</p>
  
  <pre><code>json.Unmarshal([]byte(str), &amp;res)
  s := reflect.ValueOf(&amp;res).Elem()
  typeOfT := s.Type()
  for i := 0; i &lt; s.NumField(); i++ {
      f := s.Field(i)
      v := reflect.ValueOf(f.Interface())
      if (reflect.DeepEqual(v.Interface(), reflect.Zero(v.Type()).Interface())) {
      ....
  </code></pre>
  
  <p>But the problem, of course, is that this will not work well for <code>bool</code> or <code>int</code> values.
  If a <code>bool</code> field is set to <code>false</code> in the JSON or an <code>int</code> field is set to <code>0</code>, they will be equal to the zero value of their type. The aforementioned check will consider the fields to be uninitialized, even though they actually have a value set.</p>
  
  <p>I know one way around this is to use pointers, but I just don't see how that would be possible in this case as I'm working with <code>reflect.Value</code> types, not the actual <code>struct</code>.</p>