func UserFromJSON(userJSON []byte) (*User, error) {
	user := new(User)
	err := json.Unmarshal(userJSON, user)
	if err != nil {
		log.Println(err.Error())
		return nil, err
	}
	return user, nil
}
Transform JSON into a User object
package models
import (
	"database/sql"
	"encoding/json"
	_ "github.com/lib/pq"
	"github.com/markbates/going/nulls"
	"log"
)
var userSQL UserDataLayer
const (
	EXISTS  = iota
	DELETED = iota
	ALL     = iota
)
type User struct {
	LoginID     int              `json:"loginid"`
	Name        string           `json:"name, omitempty"`
	Email       nulls.String `json:"email”`
	Password    string           `json:"password" out:"false"`
	DeletedUser bool             `json:”deleted”`
	DelOn       nulls.Time   `json:”deletedon”`
}
func NewUser(loginID int, delFilter int) (*User, error) {
	user := new(User)
	deleted1 := false
	deleted2 := false
	switch delFilter {
	case DELETED:
		deleted1 = true
		deleted2 = true
	case ALL:
		deleted2 = true
	}
	row := userSQL.GetByID.QueryRow(loginID, deleted1, deleted2)
	err := row.Scan(&user.LoginID, &user.Name, &user.Email, &user.Password, &user.DeletedUser, &user.DelOn)
	if err != nil {
		log.Println(err.Error())
		return nil, err
	}
	return user, nil
}