func marshalOne(model interface{}) (*OnePayload, error) {
	included := make(map[string]*Node)
	rootNode, err := visitModelNode(model, &included, true)
	if err != nil {
		return nil, err
	}
	payload := &OnePayload{Data: rootNode}
	payload.Included = nodeMapValues(&included)
	return payload, nil
}
marshalOne does the same as MarshalOnePayload except it just returns the
payload and doesn't write out results. Useful is you use your JSON rendering
library.
package jsonapi
import (
	"encoding/json"
	"errors"
	"fmt"
	"io"
	"reflect"
	"strconv"
	"strings"
	"time"
)
var (
	ErrBadJSONAPIStructTag = errors.New("Bad jsonapi struct tag format")
	ErrBadJSONAPIID = errors.New(
		"id should be either string, int(8,16,32,64) or uint(8,16,32,64)")
	ErrExpectedSlice = errors.New("models should be a slice of struct pointers")
	ErrUnexpectedType = errors.New("models should be a struct pointer or slice of struct pointers")
)
func MarshalPayload(w io.Writer, models interface{}) error {
	payload, err := Marshal(models)
	if err != nil {
		return err
	}
	return json.NewEncoder(w).Encode(payload)
}
func Marshal(models interface{}) (Payloader, error) {
	switch vals := reflect.ValueOf(models); vals.Kind() {
	case reflect.Slice:
		m, err := convertToSliceInterface(&models)
		if err != nil {
			return nil, err
		}
		payload, err := marshalMany(m)
		if err != nil {
			return nil, err
		}
		if linkableModels, isLinkable := models.(Linkable); isLinkable {
			jl := linkableModels.JSONAPILinks()
			if er := jl.validate(); er != nil {
				return nil, er
			}
			payload.Links = linkableModels.JSONAPILinks()
		}
		if metableModels, ok := models.(Metable); ok {
			payload.Meta = metableModels.JSONAPIMeta()
		}
		return payload, nil
	case reflect.Ptr:
		if reflect.Indirect(vals).Kind() != reflect.Struct {
			return nil, ErrUnexpectedType
		}
		return marshalOne(models)
	default:
		return nil, ErrUnexpectedType
	}
}
func MarshalPayloadWithoutIncluded(w io.Writer, model interface{}) error {
	payload, err := Marshal(model)
	if err != nil {
		return err
	}
	payload.clearIncluded()
	return json.NewEncoder(w).Encode(payload)
}