app/app.go
func (app *App) MarshalJSON() ([]byte, error) {
	repo, _ := repository.Manager().GetRepository(app.Name)
	result := make(map[string]interface{})
	result["name"] = app.Name
	result["platform"] = app.Platform
	if version := app.GetPlatformVersion(); version != "latest" {
		result["platform"] = fmt.Sprintf("%s:%s", app.Platform, version)
	}
	result["teams"] = app.Teams
	units, err := app.Units()
	result["units"] = units
	var errMsgs []string
	if err != nil {
		errMsgs = append(errMsgs, fmt.Sprintf("unable to list app units: %+v", err))
	}
	result["repository"] = repo.ReadWriteURL
	plan := map[string]interface{}{
		"name":     app.Plan.Name,
		"memory":   app.Plan.Memory,
		"swap":     app.Plan.Swap,
		"cpushare": app.Plan.CpuShare,
	}
	routers, err := app.GetRoutersWithAddr()
	if err != nil {
		errMsgs = append(errMsgs, fmt.Sprintf("unable to get app addresses: %+v", err))
	}
	if len(routers) > 0 {
		result["ip"] = routers[0].Address
		plan["router"] = routers[0].Name
		result["router"] = routers[0].Name
		result["routeropts"] = routers[0].Opts
	}
	result["cname"] = app.CName
	result["owner"] = app.Owner
	result["pool"] = app.Pool
	result["description"] = app.Description
	result["deploys"] = app.Deploys
	result["teamowner"] = app.TeamOwner
	result["plan"] = plan
	result["lock"] = app.Lock
	result["tags"] = app.Tags
	result["routers"] = routers
	if len(errMsgs) > 0 {
		result["error"] = strings.Join(errMsgs, "\n")
	}
	return json.Marshal(&result)
}
func (app *App) MarshalJSON() ([]byte, error) {
	repo, _ := repository.Manager().GetRepository(app.Name)
	result := make(map[string]interface{})
	result["name"] = app.Name
	result["platform"] = app.Platform
	if version := app.GetPlatformVersion(); version != "latest" {
		result["platform"] = fmt.Sprintf("%s:%s", app.Platform, version)
	}
	result["teams"] = app.Teams
	units, err := app.Units()
	result["units"] = units
	var errMsgs []string
	if err != nil {
		errMsgs = append(errMsgs, fmt.Sprintf("unable to list app units: %+v", err))
	}
	result["repository"] = repo.ReadWriteURL
	plan := map[string]interface{}{
		"name":     app.Plan.Name,
		"memory":   app.Plan.Memory,
		"swap":     app.Plan.Swap,
		"cpushare": app.Plan.CpuShare,
	}
	routers, err := app.GetRoutersWithAddr()
	if err != nil {
		errMsgs = append(errMsgs, fmt.Sprintf("unable to get app addresses: %+v", err))
	}
	if len(routers) > 0 {
		result["ip"] = routers[0].Address
		plan["router"] = routers[0].Name
		result["router"] = routers[0].Name
		result["routeropts"] = routers[0].Opts
	}
	result["cname"] = app.CName
	result["owner"] = app.Owner
	result["pool"] = app.Pool
	result["description"] = app.Description
	result["deploys"] = app.Deploys
	result["teamowner"] = app.TeamOwner
	result["plan"] = plan
	result["lock"] = app.Lock
	result["tags"] = app.Tags
	result["routers"] = routers
	if len(errMsgs) > 0 {
		result["error"] = strings.Join(errMsgs, "\n")
	}
	return json.Marshal(&result)
}
// MarshalJSON marshals the app in json format.