一、通过decode来解析

package Controller

import (
	"bufio"
	"encoding/json"
	"os"
)

type App struct {
	App_port string `json:"app_port"`
}
type APPName struct {
	App_host string `json:"app_host"`
	App_addr string `json:"app_addr"`
	App App `json:"app"`
}

type Name struct {
	App_name APPName `json:"app_name"`
}

var name *Name

func Unmshare(path string) (*Name,error){

	file, err :=os.Open(path)
	if err !=nil{
		panic(err)
	}
	reader :=bufio.NewReader(file)
	decoder :=json.NewDecoder(reader)
	if err =decoder.Decode(&name);err !=nil{
		return nil,err
	}

	return name,nil
}

  

相关文章:

  • 2022-12-23
  • 2021-07-18
  • 2021-05-27
  • 2021-11-18
  • 2022-02-25
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-02-12
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2023-03-21
相关资源
相似解决方案