title: JSON unmarshal does not output in my code, works in goplayground
body: <p>After reviewing several questions, I have decided to ask my question.  A few things I can say...</p>
  
  <ul>
  <li>The struct I am inserting json data into is exported, and so are its fields.</li>
  <li>The struct I am inserting json data into was auto-generated by protoc.</li>
  <li>The struct and code I am using works in goplayground <a href="https://goplay.space/#WZWs3dsVcR5" rel="nofollow noreferrer">https://goplay.space/#WZWs3dsVcR5</a></li>
  </ul>
  
  <p>The code I have is broken into a few parts.</p>
  
  <p>protofile message defining the QueryParm struct.</p>
  
  <pre class="lang-proto prettyprint-override"><code>message QueryParm {
    string column_name = 1;
    string column_type = 2;
  }
  </code></pre>
  
  <p>My struct in <code>protobuf.pb.go</code></p>
  
  <pre class="lang-golang prettyprint-override"><code>type QueryParm struct {
      ColumnName           string   `protobuf:"bytes,1,opt,name=column_name,json=columnName,proto3" json:"column_name,omitempty"`
      ColumnType           string   `protobuf:"bytes,2,opt,name=column_type,json=columnType,proto3" json:"column_type,omitempty"`
      WhereValue           string   `protobuf:"bytes,3,opt,name=where_value,json=whereValue,proto3" json:"where_value,omitempty"`
      XXX_NoUnkeyedLiteral struct{} `json:"-"`
      XXX_unrecognized     []byte   `json:"-"`
      XXX_sizecache        int32    `json:"-"`
  }
  </code></pre>
  
  <p>My data in <code>pg_client.go</code></p>
  
  <pre class="lang-golang prettyprint-override"><code>type PgData struct {
      ...
      QueryParms   string    `orm:"null"`
      ...
  }
  </code></pre>
  
  <p>And my function in grpc_client.go</p>
  
  <pre class="lang-golang prettyprint-override"><code>func createJobResponse(d *pg.PgData) (*pb.JobResponse, error) {
      var qp []*pb.QueryParm
  
      if d.QueryParms == *new(string) {
          d.QueryParms = "[{}]"
      }
      fmt.Printf("Parms: %v\nType: %T\n", d.QueryParms, d.QueryParms)
      if err := json.Unmarshal([]byte(d.QueryParms), &amp;qp); err != nil {
          return nil, err
      }
      fmt.Printf("Parms: %v\nType: %T\n", qp, qp)
      return &amp;pb.JobResponse{
          ...
          QueryParms:   qp,
          ...
      }, nil
  }
  </code></pre>
  
  <p>The output I am receiving post Unmarshal is empty in my code, and contains empty QueryParm struct pointers in the playground.  The JSON string clearly exists beforehand.</p>
  
  <pre><code>Parms: [{"ColumnName":"message_property_assetId","ColumnType":"string"},{"ColumnName":"id","ColumnType":"string"},{"ColumnName":"message_id","ColumnType":"string"},{"ColumnName":"message_security_tenantId","ColumnType":"string"}]
  Type: string
  Parms: [   ]
  Type: []*proto_export.QueryParm
  </code></pre>
  
  <p>Is there some reason why the output from my code and the playground should differ?</p>
  
  <p><strong>CONCLUSION EDIT:</strong> </p>
  
  <p>I wanted to say that for some strange reason, I was using a different struct to encode my JSON than I was to decode it.  This caused the JSON field names to be different and prevented the JSON from being decoded properly.</p>
  
  <p>Make sure you use the same struct to encode as you do to decode!</p>