title: json: invalid use of string struct tag
body: <p>I'm trying to write simple POST serverless Go AWS lambda function.</p>
  <pre><code>package main
  
  import (
      &quot;fmt&quot;
  )
  
  import (
      &quot;encoding/json&quot;
      &quot;github.com/aws/aws-lambda-go/events&quot;
      &quot;github.com/aws/aws-lambda-go/lambda&quot;
  )
  
  // RequestBodyType is our self-made struct to process JSON request from Client
  type RequestBodyType struct {
      Event       string `string:&quot;event,string,omitempty&quot;`
      EventParams EventParamsType
  }
  
  // ResponseBodyType is our self-made struct to build response for Client
  type ResponseBodyType struct {
      Event       string `string:&quot;event,string,omitempty&quot;`
      EventParams EventParamsType
  }
  
  // Probably problematic struct?
  type EventParamsType struct {
      Name string `json:&quot;name,string,omitempty&quot;`
      Age  int64  `json:&quot;age,omitempty&quot;`
  }
  
  // Handler function Using AWS Lambda Proxy Request
  func Handler(request events.APIGatewayProxyRequest) (events.APIGatewayProxyResponse, error) {
  
      // RequestBody will be used to take the json response from client and build it
      requestBody := RequestBodyType{
          Event: &quot;&quot;,
          EventParams: EventParamsType{
              Name: &quot;&quot;,
              Age:  0,
          },
      }
  
      // Unmarshal the json, return 404 if error
      err := json.Unmarshal([]byte(request.Body), &amp;requestBody)
      if err != nil {
          return events.APIGatewayProxyResponse{Body: err.Error(), StatusCode: 404}, nil
      }
  
      // We will build the BodyResponse and send it back in json form
      responseBody := &amp;ResponseBodyType{
          Event:       requestBody.Event,
          EventParams: EventParamsType{
              Name: requestBody.EventParams.Name,
              Age: requestBody.EventParams.Age,   
          },
      }
  
      fmt.Println(&quot;RESPONSE BODY&quot;)
      fmt.Println(responseBody)
  
      // Marshal the response into json bytes, if error return 404
      response, err := json.Marshal(&amp;responseBody)
      if err != nil {
          return events.APIGatewayProxyResponse{Body: err.Error(), StatusCode: 404}, nil
      }
  
      //Returning response with AWS Lambda Proxy Response
      return events.APIGatewayProxyResponse{Body: string(response), StatusCode: 200}, nil
  }
  
  func main() {
      lambda.Start(Handler)
  }
  </code></pre>
  <p>Everything works fine if I make curl request with single JSON object key, for example:</p>
  <pre><code>curl -X POST https://my.url/dev/event  -d '{&quot;event&quot;: &quot;test&quot;}'
  </code></pre>
  <p>And I get response</p>
  <pre><code>{&quot;Event&quot;:&quot;test&quot;,&quot;EventParams&quot;:{}
  </code></pre>
  <p>But if I make request with nested json object, for example:</p>
  <pre><code>curl -X POST https://my.url/dev/event  -d '{&quot;event&quot;: &quot;test&quot;,&quot;eventParams&quot;: {&quot;name&quot;: &quot;peter&quot;,&quot;age&quot;: 13}}'
  </code></pre>
  <p>Then I get response</p>
  <pre><code>json: invalid use of ,string struct tag, trying to unmarshal &quot;peter&quot; into string
  </code></pre>
  <p>I believe I have probably design EventParamsType wrong way? Or am I building ResponseBodyType wrong way?</p>