• <th id="hqbcw"></th>

  • <dd id="hqbcw"></dd>
    1. <tbody id="hqbcw"><noscript id="hqbcw"></noscript></tbody>
      <button id="hqbcw"><object id="hqbcw"></object></button>

      <tbody id="hqbcw"><pre id="hqbcw"></pre></tbody>

      在線JSON轉Golang Struct

      我要格式化json json轉postman
      type JSONData struct {
      	Name string `json:"name"`
      	Code int `json:"code"`
      	List []struct {
      		Day int `json:"day"`
      	} `json:"list"`
      }
      使用結構體
      package main
      
      import (
          "encoding/json"
          "fmt"
      )
      
      type JSONData struct {
          Name string `json:"name"`
          Code int    `json:"code"`
          List []List `json:"list"`
      }
      type List struct {
          Day int `json:"day"`
      }
      
      func main() {
          var jsonData JSONData
          jsonData.List = append(jsonData.List, List{1})
          jsonData.List = append(jsonData.List, List{2})
      
          respJson := JSONData{
              Code: 1,
              Name: "小芳",
              List: jsonData.List,
          }
          b, err := json.Marshal(respJson)
          if err != nil {
              fmt.Println("JSON ERR:", err)
          }
          fmt.Println(string(b))
      }
                          

      在線json轉golang struct工具:golang轉換成json需要先定義好結構體,如果json字段過多我們工作量會越來越大,bejson提供的這個在線json轉 golang struct工具來快速生成我們需要的結構體。

      您最近使用了:

      收藏 菜單 QQ