func (r *JSONRenderer) WeightHistory(weights []model.Weight, config *model.Config) (string, error) {
	type weightUnit struct {
		Created   time.Time `json:"created"`
		Weight    float64   `json:"weight"`
		Formatted string    `json:"formatted"`
	}
	var res []*weightUnit
	for _, w := range weights {
		weight := w.Weight
		if config.UnitSystem == util.Imperial {
			weight = util.ToPounds(weight)
		}
		res = append(res, &weightUnit{
			Created:   w.Created,
			Weight:    weight,
			Formatted: util.WeightUnit(config.UnitSystem, w.Weight),
		})
	}
	b, err := json.Marshal(res)
	if err != nil {
		return "", fmt.Errorf("could not marshal json, %v", err)
	}
	return string(b), nil
}
WeightHistory renders all weights in order and their dates
package renderer
import (
	"encoding/json"
	"fmt"
	"github.com/zupzup/calories/model"
	"github.com/zupzup/calories/util"
	"time"
)
type success struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
}
type JSONRenderer struct{}
func (r *JSONRenderer) Error(err error) (string, error) {
	res := success{
		Success: false,
		Message: err.Error(),
	}
	b, err := json.Marshal(res)
	if err != nil {
		return "", fmt.Errorf("could not marshal json, %v", err)
	}
	return string(b), nil
}