title: How to decode JSON with type convert from string to integer in Golang for non-local types?
body: <p>Below is the actual struct type in aws go sdk elbv2 package. 
  There are other parameters in this struct. I have kept only the necessary ones for simplicity.</p>
  
  <pre><code>type CreateTargetGroupInput struct {
      _ struct{} `type:"structure"`
      Name *string `type:"string" required:"true"`
      Port *int64 `min:"1" type:"integer" required:"true"`
      Protocol *string `type:"string" required:"true" enum:"ProtocolEnum"`
      VpcId *string `type:"string" required:"true"`
  }  
  </code></pre>
  
  <p>I need to decode a JSON string with integer number like:</p>
  
  <pre><code>{ "name": "test-tg", "port": "8080", "protocol": "HTTP" ,"vpcId": "vpc-xxxxxx"}
  </code></pre>
  
  <p>go code:</p>
  
  <pre><code>func main() {
      s := `{ "name": "test-tg", "port": "8080", "protocol": "HTTP" ,"vpcId": "vpc-xxxxxx"}`
  
      targetGroupInput := &amp;elbv2.CreateTargetGroupInput{}
      err := json.Unmarshal([]byte(s), targetGroupInput)
  
      if err == nil {
          fmt.Printf("%+v\n", targetGroupInput)
      }
  }
  </code></pre>
  
  <p>I'm getting the below output, (if I pass port in integer format it'll work)</p>
  
  <pre><code>{
      Name: "testTG",
      Port: 0,
      Protocol: "HTTP",
      VpcId: "vpc-0f2c8a76"
  }
  </code></pre>
  
  <p>My question is there is no json field in the original struct, so whatever valid name I pass as json field, it is still maaping to go field. 
  i.e. I can send Name field as </p>
  
  <pre><code>"name, Name, NamE, etc" 
  </code></pre>
  
  <p>in json and it still works.</p>
  
  <p>I'm confused here. For other user defined struct it wont map properly if I don't provide valid json name as defined against that go field.</p>
  
  <p>Also how do I convert Port to integer from string during Json Unmarshlling? </p>
  
  <p>As of now I'm using the exact copy of the struct in my project and removing the string type to integer for all integer type fields (also removed all pointers from all struct fields) and receiving the json object and I'm then converting it to integer and making the object of original struct.</p>
  
  <p>It takes more time for me to maintain the exact copy by doing some changes in my project folder and to do validation against all such parameters. </p>
  
  <p>I have the following questions.</p>
  
  <ol>
  <li>Is there a way to convert string to integer during unmarshlling without adding json tag like (<code>json:",string"</code>) against the integer field.</li>
  <li>Is it a good practice to maintain an exact copy of the struct (struct of elbv2 package) with few changes?</li>
  </ol>